Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge in most forks #167

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6d88e5e
Added columns group_price and base_group_price to column-list to fix …
Apr 26, 2012
92250c4
Fixed "Unknown column 'pi.base_group_price' in 'field list'" - should…
Apr 27, 2012
8742592
adding modman distribution filewq
jonpday May 18, 2012
07f5c01
fix for 1.7/1.12 compatibility re https://github.com/organicinternet/…
jonpday May 18, 2012
5b62204
fix for 1.7/1.12 compatibility re https://github.com/organicinternet/…
jonpday May 18, 2012
bba22ab
Resync product stock index resource class override with changes made …
roscius May 19, 2012
44855a7
Prevent javascript errors if the original select element in catalog/p…
May 20, 2012
87ca4de
Fix bug with group price on cofigurable product in the price index,
roscius May 21, 2012
af333e2
Resync product stock index resource class override with changes made …
roscius May 19, 2012
1700da2
applying 44855a7b75046bad256c6fdd14e16a9384160da8 from github.com/med…
jonpday Jun 22, 2012
105d6de
Merge remote-tracking branch 'mediarox/patch-1' into 17compatible
jonpday Jun 22, 2012
5e250ce
Merge remote-tracking branch 'magdev/patch-1' into 17compatible
jonpday Jun 22, 2012
5808c0c
Merge remote-tracking branch 'roscius/master' into 17compatible
jonpday Jun 22, 2012
4db7622
Sync product resource and price indexing with Magento CE 1.7
Jul 12, 2012
c01bb30
Js for reloadPrice doesn't get correct price for text options
Jul 17, 2012
eddf35a
Switch CatalogRule to Magento 1.7's way of doing resource classes
Jul 18, 2012
46bee60
remove unneeded logging
Jul 19, 2012
fe0c1f5
Strart to add French localization
Jul 23, 2012
36c0744
fix price resetting to zero when custom option checkbox is clicked
dmtw Jul 24, 2012
1c1c031
Add localization to modman/modgit
Jul 24, 2012
8da3c97
remove unneeded logging
Jul 19, 2012
ec9c821
Switch CatalogRule to Magento 1.7's way of doing resource classes
Jul 18, 2012
176cc35
Js for reloadPrice doesn't get correct price for text options
Jul 17, 2012
ea64a30
add SKU and stock availability information to spConfig object and upd…
jonpday Jul 25, 2012
9e88b33
add product alert html to the spConfig object
jonpday Jul 26, 2012
2c06b4f
Update french translation
Jul 26, 2012
9b31033
Merge branch 'master' of https://github.com/dmtw/magento-configurable…
Jul 26, 2012
f8314ac
Merge branch '17compatible' of https://github.com/aligent/magento-con…
Jul 26, 2012
2d70ea0
JS fixes for price resetting to zero when selecting product option
Jul 26, 2012
6ccc834
Fixed stock status and expanded dynamic js functions
Sep 18, 2012
8c7586f
check that the product-sku DOM element is present before updating it
jonpday Oct 18, 2012
85ab000
Allow SCP Ajax controller to display tier pricing when the parent is …
aligentjim Aug 22, 2012
b6ca9b4
Compatibility with the SweetTooth rewards extension.
aligentjim Dec 20, 2012
7dc6024
Merging 1.7.2 fix pull-request
andyflan Jun 6, 2013
b4c930a
Added composer.json
Aug 23, 2013
e91c9fc
composer json fix
Aug 23, 2013
d0c54a9
Restructured template files & added modman
Aug 23, 2013
c084166
Update composer.json
jharrisonio Sep 2, 2013
b2db34a
Removed logging call and fixed some block types
Sep 3, 2013
e03b3fe
Merge branch 'master' of https://github.com/blissmedia/organicinterne…
Sep 3, 2013
278110a
Merge remote-tracking branch 'remotes/andyflan/master'
J0s3f Sep 26, 2013
6421ce8
Merge remote-tracking branch 'remotes/aligent/master'
J0s3f Sep 26, 2013
7a5fb70
german translation
Nov 19, 2012
f6f8618
de_DE Language Support
J0s3f Sep 26, 2013
c660bab
fixed layout xml filename
nhp Oct 1, 2013
f1590cd
adapted more pathes
nhp Oct 1, 2013
7ef8eda
adapted more pathes
nhp Oct 1, 2013
a842736
finalized modman pathes
nhp Oct 1, 2013
d70c3e7
Merge pull request #1 from nhp/master
J0s3f Oct 1, 2013
7e2f91f
Merge jhuriez fork
insanityinside Feb 13, 2014
e869c7b
Merge barbazul fork
insanityinside Feb 13, 2014
8d6f8a3
Merge pull request #2 from microchip/master
J0s3f Feb 13, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function getJsonConfig()
$productId = $product->getId();
$childProducts[$productId] = array(
"price" => $this->_registerJsPrice($this->_convertPrice($product->getPrice())),
"finalPrice" => $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice()))
"finalPrice" => $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice())),
"sku" => $product->getSku(),
);

if (Mage::getStoreConfig('SCP_options/product_page/change_name')) {
Expand All @@ -34,13 +35,36 @@ public function getJsonConfig()
->toHtml();
}

$bChangeStock = Mage::getStoreConfig('SCP_options/product_page/change_stock');
if ($bChangeStock) {
// Stock status HTML
$oStockBlock = $this->getLayout()->createBlock('catalog/product_view_type_simple')->setTemplate('catalog/product/view/scpavailability.phtml');
$childProducts[$productId]["stockStatus"] = $oStockBlock->setProduct($product)->toHtml();

// Add to cart button
$oAddToCartBlock = $this->getLayout()->createBlock('catalog/product_view_type_simple')->setTemplate('catalog/product/view/addtocart.phtml');
$childProducts[$productId]["addToCart"] = $oAddToCartBlock->setProduct($product)->toHtml();
}

$bShowProductAlerts = Mage::getStoreConfig(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW);
if ($bShowProductAlerts && !$product->isAvailable()) {
$oAlertBlock = $this->getLayout()->createBlock('productalert/product_view')
->setTemplate('productalert/product/view.phtml')
->setSignupUrl(Mage::helper('productalert')->setProduct($product)->getSaveUrl('stock'));;
$childProducts[$productId]["alertHtml"] = $oAlertBlock->toHtml();
}

#if image changing is enabled..
if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
#but dont bother if fancy image changing is enabled
if (!Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
#If image is not placeholder...
if($product->getImage()!=='no_selection') {
$childProducts[$productId]["imageUrl"] = (string)Mage::helper('catalog/image')->init($product, 'image');
$productMag = Mage::getModel('catalog/product')->load($productId);
foreach($productMag->getMediaGalleryImages() as $image)
{
$childProducts[$productId]["imageUrl"][] = (string)Mage::helper('catalog/image')->init($product, 'image', $image->getFile());
}
}
}
}
Expand Down Expand Up @@ -75,14 +99,25 @@ public function getJsonConfig()
$config['shortDescription'] = $this->helper('catalog/output')->productAttribute($p, nl2br($p->getShortDescription()), 'short_description');

if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
$config["imageUrl"] = (string)Mage::helper('catalog/image')->init($p, 'image');
foreach($p->getMediaGalleryImages() as $image)
{
$config["imageUrl"][] = (string)Mage::helper('catalog/image')->init($p, 'image', $image->getFile());
}
}

$childBlock = $this->getLayout()->createBlock('catalog/product_view_attributes');
$config["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')
->setProduct($this->getProduct())
->toHtml();

$bShowProductAlerts = Mage::getStoreConfig(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW);
if ($bShowProductAlerts && !Mage::registry('child_product')->isAvailable()) {
$oAlertBlock = $this->getLayout()->createBlock('productalert/product_view')
->setTemplate('productalert/product/view.phtml')
->setSignupUrl(Mage::helper('productalert')->setProduct(Mage::registry('child_product'))->getSaveUrl('stock'));;
$config["alertHtml"] = $oAlertBlock->toHtml();
}

if (Mage::getStoreConfig('SCP_options/product_page/change_image')) {
if (Mage::getStoreConfig('SCP_options/product_page/change_image_fancy')) {
$childBlock = $this->getLayout()->createBlock('catalog/product_view_media');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function prepareForCart(Varien_Object $buyRequest, $product = null)
public function hasConfigurableProductParentId()
{
$cpid = $this->getCpid();
Mage::log("cpid: ". $cpid);
//Mage::log("cpid: ". $cpid);
return !empty($cpid);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Product_Collection
extends Mage_Catalog_Model_Resource_Product_Collection
{
/**
* Adds an additional indexed_price column to as the regular price gets over-ridden elsewhere\
*
* This field seems to only appear when the collection has ->addPriceData();
*
* @see Mage_Catalog_Model_Resource_Product_Collection::_productLimitationJoinPrice()
*/
protected function _productLimitationPrice($joinLeft = false)
{
$filters = $this->_productLimitationFilters;
if (empty($filters['use_price_index'])) {
return $this;
}

$helper = Mage::getResourceHelper('core');
$connection = $this->getConnection();
$select = $this->getSelect();
$joinCond = join(' AND ', array(
'price_index.entity_id = e.entity_id',
$connection->quoteInto('price_index.website_id = ?', $filters['website_id']),
$connection->quoteInto('price_index.customer_group_id = ?', $filters['customer_group_id'])
));

$fromPart = $select->getPart(Zend_Db_Select::FROM);
if (!isset($fromPart['price_index'])) {
$least = $connection->getLeastSql(array('price_index.min_price', 'price_index.tier_price'));
$minimalExpr = $connection->getCheckSql('price_index.tier_price IS NOT NULL',
$least, 'price_index.min_price');
$indexedExpr = new Zend_Db_Expr('price_index.price');
$colls = array('indexed_price'=>$indexedExpr,'price', 'tax_class_id', 'final_price',
'minimal_price'=>$minimalExpr , 'min_price', 'max_price', 'tier_price');
$tableName = array('price_index' => $this->getTable('catalog/product_index_price'));
if ($joinLeft) {
$select->joinLeft($tableName, $joinCond, $colls);
} else {
$select->join($tableName, $joinCond, $colls);
}
// Set additional field filters
foreach ($this->_priceDataFieldFilters as $filterData) {
$select->where(call_user_func_array('sprintf', $filterData));
}

} else {
$fromPart['price_index']['joinCondition'] = $joinCond;
$select->setPart(Zend_Db_Select::FROM, $fromPart);
}
//Clean duplicated fields
$helper->prepareColumnsList($select);

return $this;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
<?php

class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price
extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price
class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Product_Indexer_Price
extends Mage_Catalog_Model_Resource_Product_Indexer_Price
{
#Returns array of pairs (childProductId:childProductType)
/**
* Get an array of child IDs by parent product ID
*
* @param integer $parentId
*
* @return array child_id => child_product type_id
*/
private function getChildIdsByParent($parentId)
{
$read = $this->_getReadAdapter();
$select = $read->select()
#->from(array('pr' => $this->getTable('catalog/product_relation')), array('child_id'))
->from(array('p' => $this->getTable('catalog/product')), array('entity_id'))
->join(
#array('p' => $this->getTable('catalog/product')),
array('pr' => $this->getTable('catalog/product_relation')),
'pr.child_id=p.entity_id',
array('p.type_id'))
->where('pr.parent_id=?', $parentId);
return $read->fetchPairs($select);
}

/**
* Get product type from product id
*
* catalog_product_entity has the product type. Not exactly sure why
* we're using a join here, but it works.
*
* @param integer $id
* @return string Product type
*/
private function getProductTypeById($id)
{
$read = $this->_getReadAdapter();
Expand All @@ -30,20 +42,21 @@ private function getProductTypeById($id)
array('p.type_id'))
->where('pr.parent_id=?', $id);
$data = $read->fetchRow($select);
#Mage::log("SCP: getProductTypeById: result is: " . print_r($data, true));
return $data['type_id'];
}


#This is modified to pull in all sibling associated products' tier prices.
#Without this, indexed price updates only consider the tier prices of the specific
#associated product that's being saved, and it's parent
#This will often result in a non-lowest tier price being displayed, or no tier price being
#displayed when there is one (on a sibling)
#It's also updated to reindex child tier prices when a parent is saved

#Surely it's not just tier prices but all related prices this acts on?
#does copyRelationIndexData followed by reindexEntity do this itself? (just not for tier prices?)
/**
* Modified to pull in all sibling associated products' tier prices and
* to reindex child tier prices when a parent is saved.
*
* Process product save.
* Method is responsible for index support
* when product was saved and changed attribute(s) has an effect on price.
*
* @param Mage_Index_Model_Event $event
* @return Mage_Catalog_Model_Resource_Product_Indexer_Price
*/
public function catalogProductSave(Mage_Index_Model_Event $event)
{
$productId = $event->getEntityPk();
Expand All @@ -55,55 +68,40 @@ public function catalogProductSave(Mage_Index_Model_Event $event)
if (!isset($data['reindex_price'])) {
return $this;
}
$this->cloneIndexTable(true);

$this->clearTemporaryIndexTable();
$this->_prepareWebsiteDateTable();

$indexer = $this->_getIndexer($data['product_type_id']);
$processIds = array($productId);

if ($indexer->getIsComposite()) {
#Mage::log("catalogProductSave: " . "saving composite");
if ($this->getProductTypeById($productId) == 'configurable') {
#Mage::log("catalogProductSave: " . "saving composite - is configurable");
$children = $this->getChildIdsByParent($productId);
$processIds = array_merge($processIds, array_keys($children));
#Ignore tier price data for actual configurable product
//Ignore tier and group price data for actual configurable product
$tierPriceIds = array_keys($children);
} else {
$tierPriceIds = $productId;
}
#Mage::log("catalogProductSave: " . "copyRelationIndexData for: " . $productId);
$this->_copyRelationIndexData($productId);
#Mage::log("catalogProductSave: " . "_prepareTierPriceIndex for: " . print_r($tierPriceIds, true));
$this->_prepareTierPriceIndex($tierPriceIds);
#Mage::log("catalogProductSave: " . "reindexEntity for: " . $productId);
$this->_prepareGroupPriceIndex($tierPriceIds);
$indexer->reindexEntity($productId);
} else {
#Mage::log("catalogProductSave: " . "saving non-composite");
$parentIds = $this->getProductParentsByChild($productId);

if ($parentIds) {
#Mage::log("catalogProductSave: " . "non-composite product: " . $productId . " has parents: " . print_r($parentIds, true));

#Prepare to process parents too
$processIds = array_merge($processIds, array_keys($parentIds));

$siblingIds = array();
foreach (array_keys($parentIds) as $parentId) {
$childIds = $this->getChildIdsByParent($parentId);
#Mage::log("catalogProductSave: For parent_id: $parentId, adding childIds of: " . print_r($childIds, true));
$siblingIds = array_merge($siblingIds, array_keys($childIds));
}
#Mage::log("catalogProductSave: siblingIds are: " . print_r($siblingIds, true));
if(count($siblingIds)>0) {
$processIds = array_unique(array_merge($processIds, $siblingIds));
}
#Mage::log("catalogProductSave: " . "copyRelationIndexData for: " . print_r(array_keys($parentIds), true) . "ignoring relation: " . $productId);
$this->_copyRelationIndexData(array_keys($parentIds), $productId);

#Mage::log("catalogProductSave: " . "_prepareTierPriceIndex for: " . print_r($processIds, true));
$this->_prepareTierPriceIndex($processIds);
#Mage::log("catalogProductSave: " . "reindexEntity for: " . $productId);
$this->_prepareGroupPriceIndex($processIds);
$indexer->reindexEntity($productId);

$parentByType = array();
Expand All @@ -112,13 +110,11 @@ public function catalogProductSave(Mage_Index_Model_Event $event)
}

foreach ($parentByType as $parentType => $entityIds) {
#Mage::log("catalogProductSave: " . "reindexEntity using indexer of type: " . $parentType . " for: " . print_r($entityIds, true));
$this->_getIndexer($parentType)->reindexEntity($entityIds);
}

} else {
#Mage::log("catalogProductSave: " . "non-composite product: " . $productId . " has no parents");
$this->_prepareTierPriceIndex($productId);
$this->_prepareGroupPriceIndex($productId);
$indexer->reindexEntity($productId);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Configurable
class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Product_Indexer_Price_Configurable
extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Configurable
{
protected function _isManageStock()
Expand Down Expand Up @@ -84,8 +84,8 @@ protected function _prepareFinalPriceData($entityIds = null)
'max_price' => new Zend_Db_Expr('pi.final_price'),
'tier_price' => new Zend_Db_Expr('pi.tier_price'),
'base_tier' => new Zend_Db_Expr('pi.tier_price'),
'group_price' => new Zend_Db_Expr('pi.tier_price'),
'base_group_price' => new Zend_Db_Expr('pi.tier_price'),
'group_price' => new Zend_Db_Expr('pi.group_price'),
'base_group_price' => new Zend_Db_Expr('pi.group_price'),
));


Expand Down Expand Up @@ -130,7 +130,6 @@ protected function _prepareFinalPriceData($entityIds = null)
'base_tier',
'group_price',
'base_group_price',
#'base_tier',
#'child_entity_id'
));
# Mage::log("SCP Price inner query: " . $select->__toString());
Expand All @@ -140,6 +139,23 @@ protected function _prepareFinalPriceData($entityIds = null)
$write->query($query);


/**
* Add possibility modify prices from external events
*/
$select = $write->select()
->join(array('wd' => $this->_getWebsiteDateTable()),
'i.website_id = wd.website_id',
array());
Mage::dispatchEvent('prepare_catalog_product_price_index_table', array(
'index_table' => array('i' => $this->_getDefaultFinalPriceTable()),
'select' => $select,
'entity_id' => 'i.entity_id',
'customer_group_id' => 'i.customer_group_id',
'website_id' => 'i.website_id',
'website_date' => 'wd.website_date',
'update_fields' => array('price', 'min_price', 'max_price')
));

return $this;
}
}
Loading