From ab023bffeeacb0fdd0bd0365f366d6f840035a0d Mon Sep 17 00:00:00 2001 From: steven Date: Thu, 18 Apr 2013 16:40:08 -0400 Subject: [PATCH] This fix is for Stores with large amounts of Products and Configurable Attributes. _loadSkuSuperAttributeValues() is given parameters and a foreach loop creates the productIds needed for the current bunch. The conversion From Sku to Id is duplicated later in save(), but I felt it is best to do the conversion here then let the DB do the work. This fix is based off of a module rewrite for EE 1.12 and has not been tested on Mage2. It should work though, That Module successfully imported 700,000 Simple Products and many Configurable Products. Most of the Configurable Products having 3 super_attributes. Signed-off-by: Steven Hoffman --- .../Import/Entity/Product/Type/Configurable.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php index 41d5285aaeba7..8d5c1fb88a136 100644 --- a/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php +++ b/app/code/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php @@ -220,18 +220,28 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum) * * @return Mage_ImportExport_Model_Import_Entity_Product_Type_Configurable */ - protected function _loadSkuSuperAttributeValues() + protected function _loadSkuSuperAttributeValues($bunch, $newSku, $oldSku) { if ($this->_superAttributes) { $attrSetIdToName = $this->_entityModel->getAttrSetIdToName(); $allowProductTypes = array(); - + + foreach ($bunch as $rowData){ + if (!empty($rowData['_super_products_sku'])) { + if (isset($newSku[$rowData['_super_products_sku']])) { + $productIdArray[] = $newSku[$rowData['_super_products_sku']]; + } elseif (isset($oldSku[$rowData['_super_products_sku']])) { + $productIdArray[] = $oldSku[$rowData['_super_products_sku']]; + } + } + } foreach (Mage::getConfig() ->getNode('global/catalog/product/type/configurable/allow_product_types')->children() as $type) { $allowProductTypes[] = $type->getName(); } foreach (Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Collection') ->addFieldToFilter('type_id', $allowProductTypes) + ->addFieldToFilter ('entity_id', array('in' => $productIdArray)) ->addAttributeToSelect(array_keys($this->_superAttributes)) as $product) { $attrSetName = $attrSetIdToName[$product->getAttributeSetId()]; @@ -362,7 +372,6 @@ public function saveData() if ($this->_entityModel->getBehavior() == Mage_ImportExport_Model_Import::BEHAVIOR_APPEND) { $this->_loadSkuSuperData(); } - $this->_loadSkuSuperAttributeValues(); while ($bunch = $this->_entityModel->getNextBunch()) { $superAttributes = array( @@ -372,6 +381,7 @@ public function saveData() 'super_link' => array(), 'relation' => array() ); + $this->_loadSkuSuperAttributeValues($bunch, $newSku, $oldSku); foreach ($bunch as $rowNum => $rowData) { if (!$this->_entityModel->isRowAllowedToImport($rowData, $rowNum)) { continue;