diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Block/Product/View/Type/Configurable.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Block/Product/View/Type/Configurable.php index 7086d24..4b468d4 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Block/Product/View/Type/Configurable.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Block/Product/View/Type/Configurable.php @@ -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')) { @@ -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()); + } } } } @@ -75,7 +99,10 @@ 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'); @@ -83,6 +110,14 @@ public function getJsonConfig() ->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'); diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Product/Type/Simple.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Product/Type/Simple.php index fed7bef..7b4a08b 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Product/Type/Simple.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Product/Type/Simple.php @@ -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); } diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php deleted file mode 100644 index 8f85575..0000000 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php +++ /dev/null @@ -1,40 +0,0 @@ -_productLimitationFilters; - if (empty($filters['use_price_index'])) { - return $this; - } - - $connection = $this->getConnection(); - - $joinCond = $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 = $this->getSelect()->getPart(Zend_Db_Select::FROM); - if (!isset($fromPart['price_index'])) { - $minimalExpr = new Zend_Db_Expr( - 'IF(`price_index`.`tier_price`, LEAST(`price_index`.`min_price`, `price_index`.`tier_price`), `price_index`.`min_price`)' - ); - $indexedExpr = new Zend_Db_Expr('price_index.price'); - $this->getSelect()->join( - array('price_index' => $this->getTable('catalog/product_index_price')), - $joinCond, - array('indexed_price'=>$indexedExpr,'price', 'final_price', 'minimal_price'=>$minimalExpr , 'min_price', 'max_price', 'tier_price')); - - } else { - $fromPart['price_index']['joinCondition'] = $joinCond; - $this->getSelect()->setPart(Zend_Db_Select::FROM, $fromPart); - } - - return $this; - } -} diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Collection.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Collection.php new file mode 100644 index 0000000..bbf6a28 --- /dev/null +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Collection.php @@ -0,0 +1,56 @@ +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; + } +} diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Indexer/Price.php similarity index 56% rename from app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php rename to app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Indexer/Price.php index 21eda98..2d24d50 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Indexer/Price.php @@ -1,17 +1,20 @@ 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')) @@ -19,6 +22,15 @@ private function getChildIdsByParent($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(); @@ -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(); @@ -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(); @@ -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); } } diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Configurable.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Indexer/Price/Configurable.php similarity index 86% rename from app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Configurable.php rename to app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Indexer/Price/Configurable.php index 8e26148..cc44314 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Configurable.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Model/Resource/Product/Indexer/Price/Configurable.php @@ -1,5 +1,5 @@ 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'), )); @@ -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()); @@ -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; } } diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogInventory/Model/Mysql4/Indexer/Stock/Configurable.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php similarity index 67% rename from app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogInventory/Model/Mysql4/Indexer/Stock/Configurable.php rename to app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php index 200379a..888b4b3 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogInventory/Model/Mysql4/Indexer/Stock/Configurable.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php @@ -1,11 +1,24 @@ _getWriteAdapter(); @@ -39,20 +52,20 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f ->where('e.type_id = ?', $this->getTypeId()) ->group(array('e.entity_id', 'cw.website_id', 'cis.stock_id')); - $this->_addProductWebsiteJoinToSelect($select, 'cw.website_id', 'le.entity_id'); #may need to use le.entity_id? + $this->_addProductWebsiteJoinToSelect($select, 'cw.website_id', 'le.entity_id'); $psExpr = $this->_addAttributeToSelect($select, 'status', 'le.entity_id', 'cs.store_id'); $psCond = $adapter->quoteInto($psExpr . '=?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); if ($this->_isManageStock()) { - $statusExpr = new Zend_Db_Expr('IF(cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0,' - . ' 1, cisi.is_in_stock)'); + $statusExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0', + 1, 'cisi.is_in_stock'); } else { - $statusExpr = new Zend_Db_Expr('IF(cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 1,' - . 'cisi.is_in_stock, 1)'); + $statusExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 1', + 'cisi.is_in_stock', 1); } - $stockStatusExpr = new Zend_Db_Expr("MAX(LEAST(IF({$psCond}, 1, 0), {$statusExpr}))"); + $stockStatusExpr = new Zend_Db_Expr("MAX(LEAST(IF({$psCond}, 1, 0), {$statusExpr}))"); $select->columns(array( 'status' => $stockStatusExpr @@ -60,8 +73,7 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f if (!is_null($entityIds)) { $select->where('e.entity_id IN(?)', $entityIds); - } - + } return $select; } } diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogRule/Model/Mysql4/Rule.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogRule/Model/Resource/Rule.php similarity index 98% rename from app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogRule/Model/Mysql4/Rule.php rename to app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogRule/Model/Resource/Rule.php index 8935ef4..6e6663f 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogRule/Model/Mysql4/Rule.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/CatalogRule/Model/Resource/Rule.php @@ -5,8 +5,8 @@ #My fix is: only delete pricerule price entries for the rule that fails to validate #It's an odd bug - and maybe there's a good reason, but it's making my rules disappear when I save products, which is pretty annoying -class OrganicInternet_SimpleConfigurableProducts_CatalogRule_Model_Mysql4_Rule extends - Mage_CatalogRule_Model_Mysql4_Rule +class OrganicInternet_SimpleConfigurableProducts_CatalogRule_Model_Resource_Rule extends + Mage_CatalogRule_Model_Resource_Rule { public function applyToProduct($rule, $product, $websiteIds) diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php index 4817f31..c65931e 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php @@ -10,10 +10,13 @@ protected function getConfigurableProductParentId() #No idea why in 1.5 the stuff in buyRequest isn't auto-decoded from info_buyRequest #but then it's Magento we're talking about, so I've not a clue what's *meant* to happen. try { - $buyRequest = unserialize($this->getItem()->getOptionByCode('info_buyRequest')->getValue()); - if(!empty($buyRequest['cpid'])) { - return $buyRequest['cpid']; + $buyRequest = $this->getItem()->getOptionByCode('info_buyRequest'); + if ($buyRequest) { + $buyRequest = unserialize($buyRequest->getValue()); } + if(!empty($buyRequest['cpid'])) { + return $buyRequest['cpid']; + } } catch (Exception $e) { } return null; diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Category.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Category.php index fa9daeb..38f756e 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Category.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Category.php @@ -69,7 +69,7 @@ protected function _toHtml() ''. ''.$_product->getDescription(). - ($_product->isConfigurable() ? '

Price From:' : '

Price:'). + ($_product->isConfigurable() ? '

Preis ab:   ' : '

Preis:'). Mage::helper('core')->currency($_product->getPrice()). ($_product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : ''). '

'. diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/New.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/New.php index 6401130..016db9c 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/New.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/New.php @@ -12,7 +12,7 @@ public function addNewItemXmlCallback($args) $description = ''. ''. '
'.$product->getDescription(). - ($product->isConfigurable() ? '

Price From:' : '

Price:'). + ($product->isConfigurable() ? '

Preis ab:   ' : '

Preis:'). Mage::helper('core')->currency($product->getPrice()). ($product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : ''). '

'. diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Special.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Special.php index ac341c0..95effba 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Special.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Special.php @@ -82,7 +82,7 @@ protected function _toHtml() $description = ''. ''. ''. '
'.$product->getDescription(). - ($product->isConfigurable() ? '

Price From:' : '

Price:'). + ($product->isConfigurable() ? '

Preis ab:  ' : '

Preis:'). Mage::helper('core')->currency($product->getPrice()). ' Special Price:'. Mage::helper('core')->currency($special_price). ($result['use_special'] && $result['special_to_date'] ? '
Special Expires on: '.$this->formatDate($result['special_to_date'], Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM) : ''). diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Tag.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Tag.php index e05d0b3..96a3222 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Tag.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Catalog/Tag.php @@ -10,7 +10,7 @@ public function addTaggedItemXml($args) $description = ''. ''. ''. '
'.$product->getDescription(). - ($product->isConfigurable() ? '

Price From:' : '

Price:'). + ($product->isConfigurable() ? '

Preis ab:  ' : '

Preis:'). Mage::helper('core')->currency($product->getFinalPrice()).'

'. '
'; diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Wishlist.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Wishlist.php index 9c45a8b..4cbfa7e 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Wishlist.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/Rss/Block/Wishlist.php @@ -45,7 +45,7 @@ protected function _toHtml() '

'. $product->getDescription(). - ($product->isConfigurable() ? '

Price From:' : '

Price:'). + ($product->isConfigurable() ? '

Preis ab:  ' : '

Preis:'). Mage::helper('core')->currency($product->getPrice()). ($product->getPrice() != $product->getFinalPrice() ? ' Special Price:'. Mage::helper('core')->currency($product->getFinalPrice()) : ''). ($item->getDescription() && $item->getDescription() != Mage::helper('wishlist')->defaultCommentString() ? '

Comment: '.$item->getDescription().'

' : ''). diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/controllers/AjaxController.php b/app/code/community/OrganicInternet/SimpleConfigurableProducts/controllers/AjaxController.php index 0544be5..bcabcdb 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/controllers/AjaxController.php +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/controllers/AjaxController.php @@ -47,8 +47,7 @@ protected function _initProduct() $parent = Mage::getModel('catalog/product') ->setStoreId(Mage::app()->getStore()->getId()) ->load($parentId); - - if (!Mage::helper('catalog/product')->canShow($parent)) { + if (!$parent->getId()) { return false; } @@ -64,6 +63,11 @@ protected function _initProduct() if (!$product->getId()) { return false; } + + if (!Mage::helper('catalog/product')->canShow($parent) && !Mage::helper('catalog/product')->canShow($product)) { + return false; + } + if ($categoryId) { $category = Mage::getModel('catalog/category')->load($categoryId); Mage::register('current_category', $category); diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/config.xml b/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/config.xml index 1e692c1..43ddb21 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/config.xml +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/config.xml @@ -12,11 +12,11 @@ - + - OrganicInternet_SimpleConfigurableProducts_CatalogRule_Model_Mysql4_Rule + OrganicInternet_SimpleConfigurableProducts_CatalogRule_Model_Resource_Rule - + OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Configurable_Price @@ -34,27 +34,29 @@ OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product + + + OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Product_Indexer_Price_Configurable + + + OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Product_Collection + + OrganicInternet_SimpleConfigurableProducts_CatalogIndex_Model_Data_Configurable - + + + OrganicInternet_SimpleConfigurableProducts_CatalogInventory_Model_Resource_Indexer_Stock_Configurable + + + - OrganicInternet_SimpleConfigurableProducts_CatalogInventory_Model_Mysql4_Indexer_Stock_Configurable + OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Product_Indexer_Price - - - - OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Collection - - - OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Configurable - - - OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price - - + @@ -104,7 +106,7 @@ - simpleconfigurableproducts.xml + scp.xml @@ -117,6 +119,15 @@ + + + + + OrganicInternet_SimpleConfigurableProducts.csv + + + + @@ -138,5 +149,14 @@ + + + + + OrganicInternet_SimpleConfigurableProducts.csv + + + + diff --git a/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/system.xml b/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/system.xml index 35c9482..93eb337 100644 --- a/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/system.xml +++ b/app/code/community/OrganicInternet/SimpleConfigurableProducts/etc/system.xml @@ -140,6 +140,16 @@ 1 1 + + + select + adminhtml/system_config_source_yesno + 999 + 1 + 1 + 1 + Takes affect once all configurable options have been selected + diff --git a/app/design/frontend/base/default/layout/simpleconfigurableproducts.xml b/app/design/frontend/base/default/layout/scp.xml similarity index 79% rename from app/design/frontend/base/default/layout/simpleconfigurableproducts.xml rename to app/design/frontend/base/default/layout/scp.xml index 22f16f3..b142c02 100644 --- a/app/design/frontend/base/default/layout/simpleconfigurableproducts.xml +++ b/app/design/frontend/base/default/layout/scp.xml @@ -6,36 +6,36 @@ but we can't necessarily guarantee the load order of the script using the addJs mechanism. Items of type 'skin_js' load after those of type 'js' however, so we use that. (See getCssJsHtml in app/code/core/Mage/Page/Block/Html/Head.php) --> - skin_jsjs/scp_product_extension.js + skin_jsjs/scp/scp_product_extension.js - + - + - + - + - + - + textcatalog/product_view_options_type_text filecatalog/product_view_options_type_file selectcatalog/product_view_options_type_select @@ -46,7 +46,7 @@ - + diff --git a/app/design/frontend/base/default/template/catalog/product/view/scpavailability.phtml b/app/design/frontend/base/default/template/catalog/product/view/scpavailability.phtml new file mode 100644 index 0000000..35d79e1 --- /dev/null +++ b/app/design/frontend/base/default/template/catalog/product/view/scpavailability.phtml @@ -0,0 +1,8 @@ + +getProduct() ?> + +isAvailable()): ?> +

__('Availability:') ?> __('In stock') ?>

+ +

__('Availability:') ?> __('Out of stock') ?>

+ diff --git a/app/design/frontend/base/default/template/catalog/product/view/options/scpwrapper.phtml b/app/design/frontend/base/default/template/scp/catalog/product/view/options/scpwrapper.phtml similarity index 81% rename from app/design/frontend/base/default/template/catalog/product/view/options/scpwrapper.phtml rename to app/design/frontend/base/default/template/scp/catalog/product/view/options/scpwrapper.phtml index bc2b479..de45690 100644 --- a/app/design/frontend/base/default/template/catalog/product/view/options/scpwrapper.phtml +++ b/app/design/frontend/base/default/template/scp/catalog/product/view/options/scpwrapper.phtml @@ -1,6 +1,6 @@
getChildHtml('', true, true);?> - +
hasRequiredOptions()):?> diff --git a/app/design/frontend/base/default/template/catalog/product/view/scpajaxoptions.phtml b/app/design/frontend/base/default/template/scp/catalog/product/view/scpajaxoptions.phtml similarity index 100% rename from app/design/frontend/base/default/template/catalog/product/view/scpajaxoptions.phtml rename to app/design/frontend/base/default/template/scp/catalog/product/view/scpajaxoptions.phtml diff --git a/app/design/frontend/base/default/template/catalog/product/view/scpoptions.phtml b/app/design/frontend/base/default/template/scp/catalog/product/view/scpoptions.phtml similarity index 98% rename from app/design/frontend/base/default/template/catalog/product/view/scpoptions.phtml rename to app/design/frontend/base/default/template/scp/catalog/product/view/scpoptions.phtml index c3571bd..fac599c 100644 --- a/app/design/frontend/base/default/template/catalog/product/view/scpoptions.phtml +++ b/app/design/frontend/base/default/template/scp/catalog/product/view/scpoptions.phtml @@ -95,7 +95,7 @@ if (count($_options) || $this->getProduct()->isConfigurable()): if (element.type == 'checkbox' || element.type == 'radio') { if (element.checked) { if (config[optionId][element.getValue()]) { - price += parseFloat(config[optionId][element.getValue()]); + price += parseFloat(config[optionId][element.getValue()].price); } } } else if(element.hasClassName('datetime-picker') && !skipIds.include(optionId)) { @@ -106,7 +106,7 @@ if (count($_options) || $this->getProduct()->isConfigurable()): } }); if (dateSelected) { - price += parseFloat(this.config[optionId]); + price += parseFloat(this.config[optionId].price); skipIds[optionId] = optionId; } } else if(element.type == 'select-one' || element.type == 'select-multiple') { @@ -114,14 +114,14 @@ if (count($_options) || $this->getProduct()->isConfigurable()): $A(element.options).each(function(selectOption){ if (selectOption.selected) { if (this.config[optionId][selectOption.value]) { - price += parseFloat(this.config[optionId][selectOption.value]); + price += parseFloat(this.config[optionId][selectOption.value].price); } } }); } } else { if (element.getValue().strip() != '') { - price += parseFloat(this.config[optionId]); + price += parseFloat(this.config[optionId].price); } } } diff --git a/app/design/frontend/base/default/template/page/scpcontentonly.phtml b/app/design/frontend/base/default/template/scp/page/scpcontentonly.phtml similarity index 100% rename from app/design/frontend/base/default/template/page/scpcontentonly.phtml rename to app/design/frontend/base/default/template/scp/page/scpcontentonly.phtml diff --git a/app/design/frontend/base/default/template/sales/reorder/scpsidebar.phtml b/app/design/frontend/base/default/template/scp/sales/reorder/scpsidebar.phtml similarity index 100% rename from app/design/frontend/base/default/template/sales/reorder/scpsidebar.phtml rename to app/design/frontend/base/default/template/scp/sales/reorder/scpsidebar.phtml diff --git a/app/locale/de_DE/OrganicInternet_SimpleConfigurableProducts.csv b/app/locale/de_DE/OrganicInternet_SimpleConfigurableProducts.csv new file mode 100644 index 0000000..9b71d73 --- /dev/null +++ b/app/locale/de_DE/OrganicInternet_SimpleConfigurableProducts.csv @@ -0,0 +1,22 @@ +"Price From:","Preis ab:" +"Last ordered items","Zuletzt bestellte Produkte" +"SCP","SCP" +"SCP Config","SCP Konfiguration" +"SCP - Cart","SCP - Warenkorb" +"Show Configurable Product Options In Cart","Zeige konfigurierbare Produkt-Optionen im Warenkorb" +"Show Custom Options In Cart","Zeige individuelle Optionen im Warenkorb" +"Show Configurable Product Name in Cart","Zeige konfigurierbare Produkt-Namen im Warenkorb" +"Show Configurable Product Image in Cart","Zeige konfigurierbares Produkt-Bild im Warenkorb" +"SCP - Product Page","SCP - Produkt Ansicht" +"Dynamically update displayed product description","Dynamisches aktualisieren der Beschreibung" +"Dynamically update displayed product short description","Dynamisches aktualisieren der Kurzbeschreibung" +"Dynamically update displayed product name","Dynamisches aktualisieren des Namen" +"Dynamically update displayed product 'additional information'","Dynamisches aktualisieren der Zusatzinformationen" +"Dynamically update displayed product picture","Dynamisches aktualisieren der Produktbilder" +"Update gallery images as well as main image?","Dynamisches aktualisieren der Produktbilder-Galerie" +"Show price ranges in Configurable Product Option dropdowns","Zeige Differenz Preise im DropDown-Menü" +"Takes affect once all configurable options have been selected","Diese Einstellung beeinflusst alle konfiguerierbaren Produkte" +"Uses ajax to pull in the correct related product images too","Benutzt AJAX um die richtigen Produktbilder zu laden" +"Only applies to SCP configurable products","Funktioniert nur bei Konfigurierbaren Produkten" +"No = Show simple product name in cart","Nein = Zeigt den Produkt-Namen des Simplen Produktes im Warenkorb" +"No = Show simple product image in cart","Nein = Zeigt das Produkt-Bild des Simplen Produktes im Warenkorb" \ No newline at end of file diff --git a/app/locale/en_US/OrganicInternet_SimpleConfigurableProducts.csv b/app/locale/en_US/OrganicInternet_SimpleConfigurableProducts.csv new file mode 100644 index 0000000..541aa6d --- /dev/null +++ b/app/locale/en_US/OrganicInternet_SimpleConfigurableProducts.csv @@ -0,0 +1,22 @@ +"Price From:","Price From:" +"Last ordered items","Last ordered items" +"SCP","SCP" +"SCP Config","SCP Config" +"SCP - Cart","SCP - Cart" +"Show Configurable Product Options In Cart","Show Configurable Product Options In Cart" +"Show Custom Options In Cart","Show Custom Options In Cart" +"Show Configurable Product Name in Cart","Show Configurable Product Name in Cart" +"Show Configurable Product Image in Cart","Show Configurable Product Image in Cart" +"SCP - Product Page","SCP - Product Page" +"Dynamically update displayed product description","Dynamically update displayed product description" +"Dynamically update displayed product short description","Dynamically update displayed product short description" +"Dynamically update displayed product name","Dynamically update displayed product name" +"Dynamically update displayed product 'additional information'","Dynamically update displayed product 'additional information'" +"Dynamically update displayed product picture","Dynamically update displayed product picture" +"Update gallery images as well as main image?","Update gallery images as well as main image?" +"Show price ranges in Configurable Product Option dropdowns","Show price ranges in Configurable Product Option dropdowns" +"Takes affect once all configurable options have been selected","Takes affect once all configurable options have been selected" +"Uses ajax to pull in the correct related product images too","Uses ajax to pull in the correct related product images too" +"Only applies to SCP configurable products","Only applies to SCP configurable products" +"No = Show simple product name in cart","No = Show simple product name in cart" +"No = Show simple product image in cart","No = Show simple product image in cart" \ No newline at end of file diff --git a/app/locale/fr_FR/OrganicInternet_SimpleConfigurableProducts.csv b/app/locale/fr_FR/OrganicInternet_SimpleConfigurableProducts.csv new file mode 100644 index 0000000..aa9d65d --- /dev/null +++ b/app/locale/fr_FR/OrganicInternet_SimpleConfigurableProducts.csv @@ -0,0 +1,2 @@ +"Price From:","À partir de:" +"Last ordered items","Derniers produits commandés" diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..63f3ee5 --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ + "name":"organicinternet/magento-configurable-simple", + "type":"magento-module", + "homepage":"https://github.com/blissmedia/organicinternet_magento-configurable-simple", + "authors":[ + { + "name":"James Harrison" + } + ], + "minimum-stability":"dev" +} diff --git a/modman b/modman new file mode 100644 index 0000000..62356e0 --- /dev/null +++ b/modman @@ -0,0 +1,13 @@ +app/code/community/OrganicInternet app/code/community/OrganicInternet +app/design/frontend/base/default/layout/scp.xml app/design/frontend/base/default/layout/scp.xml +app/design/frontend/base/default/template/scp/catalog/product/view/options/scpwrapper.phtml app/design/frontend/base/default/template/scp/catalog/product/view/options/scpwrapper.phtml +app/design/frontend/base/default/template/scp/catalog/product/view/scpajaxoptions.phtml app/design/frontend/base/default/template/scp/catalog/product/view/scpajaxoptions.phtml +app/design/frontend/base/default/template/scp/catalog/product/view/scpoptions.phtml app/design/frontend/base/default/template/scp/catalog/product/view/scpoptions.phtml +app/design/frontend/base/default/template/catalog/product/view/scpavailability.phtml app/design/frontend/base/default/template/catalog/product/view/scpavailability.phtml +app/design/frontend/base/default/template/scp/page/scpcontentonly.phtml app/design/frontend/base/default/template/scp/page/scpcontentonly.phtml +app/design/frontend/base/default/template/scp/sales/reorder/scpsidebar.phtml app/design/frontend/base/default/template/scp/sales/reorder/scpsidebar.phtml +app/etc/modules/OrganicInternet_SimpleConfigurableProducts.xml app/etc/modules/OrganicInternet_SimpleConfigurableProducts.xml +app/locale/fr_FR/OrganicInternet_SimpleConfigurableProducts.csv app/locale/fr_FR/OrganicInternet_SimpleConfigurableProducts.csv +app/locale/en_US/OrganicInternet_SimpleConfigurableProducts.csv app/locale/en_US/OrganicInternet_SimpleConfigurableProducts.csv +skin/frontend/base/default/images/scp/scp-ajax-loader.gif skin/frontend/base/default/images/scp/scp-ajax-loader.gif +skin/frontend/base/default/js/scp/scp_product_extension.js skin/frontend/base/default/js/scp/scp_product_extension.js diff --git a/skin/frontend/base/default/images/scp-ajax-loader.gif b/skin/frontend/base/default/images/scp/scp-ajax-loader.gif similarity index 100% rename from skin/frontend/base/default/images/scp-ajax-loader.gif rename to skin/frontend/base/default/images/scp/scp-ajax-loader.gif diff --git a/skin/frontend/base/default/js/scp_product_extension.js b/skin/frontend/base/default/js/scp/scp_product_extension.js similarity index 89% rename from skin/frontend/base/default/js/scp_product_extension.js rename to skin/frontend/base/default/js/scp/scp_product_extension.js index 7e72154..0747f93 100644 --- a/skin/frontend/base/default/js/scp_product_extension.js +++ b/skin/frontend/base/default/js/scp/scp_product_extension.js @@ -159,6 +159,7 @@ Product.Config.prototype.reloadPrice = function() { var price = childProducts[childProductId]["price"]; var finalPrice = childProducts[childProductId]["finalPrice"]; optionsPrice.productPrice = finalPrice; + optionsPrice.productPriceBeforeRedemptions = finalPrice; optionsPrice.productOldPrice = price; optionsPrice.reload(); optionsPrice.reloadPriceLabels(true); @@ -166,6 +167,8 @@ Product.Config.prototype.reloadPrice = function() { this.updateProductShortDescription(childProductId); this.updateProductDescription(childProductId); this.updateProductName(childProductId); + this.updateProductStock(childProductId); + this.updateProductSku(childProductId); this.updateProductAttributes(childProductId); this.updateFormProductId(childProductId); this.addParentProductIdToCartForm(this.config.productId); @@ -189,6 +192,8 @@ Product.Config.prototype.reloadPrice = function() { this.updateProductShortDescription(false); this.updateProductDescription(false); this.updateProductName(false); + this.updateProductStock(false); + this.updateProductSku(false); this.updateProductAttributes(false); this.showCustomOptionsBlock(false, false); if (usingZoomer) { @@ -211,16 +216,14 @@ Product.Config.prototype.updateProductImage = function(productId) { return; } - if($('image')) { - $('image').src = imageUrl; - } else { - $$('#product_addtocart_form p.product-image img').each(function(el) { - var dims = el.getDimensions(); - el.src = imageUrl; - el.width = dims.width; - el.height = dims.height; - }); + // Galleria update + var gal = Galleria.get(0); + var dataArr = new Array(); + for(var i=0;i