Skip to content

Commit

Permalink
Merge pull request #598 from magento-troll/m2beta3
Browse files Browse the repository at this point in the history
[Merchant Beta][MX] Bugfixes for beta 3
  • Loading branch information
Slabko,Michael(mslabko) committed Sep 15, 2015
2 parents 963597a + 92bb4e6 commit 4923f81
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,23 @@ protected function _loadSkuSuperAttributeValues($bunch, $newSku, $oldSku)
/**
* Array of SKU to array of super attribute values for all products.
*
* @param array $bunch
* @return $this
*/
protected function _loadSkuSuperData()
protected function _loadSkuSuperDataForBunch(array $bunch)
{
if (!$this->_skuSuperData) {
$newSku = $this->_entityModel->getNewSku();
$oldSku = $this->_entityModel->getOldSku();
$productIds = [];
foreach ($bunch as $rowData) {
$sku = $rowData[ImportProduct::COL_SKU];
$productData = isset($newSku[$sku]) ? $newSku[$sku] : $oldSku[$sku];
$productIds[] = $productData['entity_id'];
}

$this->_productSuperAttrs = [];
$this->_skuSuperData = [];
if (!empty($productIds)) {
$mainTable = $this->_resource->getTableName('catalog_product_super_attribute');
$optionTable = $this->_resource->getTableName('eav_attribute_option');
$select = $this->_connection->select()->from(
Expand All @@ -362,6 +374,9 @@ protected function _loadSkuSuperData()
'o.attribute_id'
),
['option_id']
)->where(
'product_id IN ( ? )',
$productIds
);

foreach ($this->_connection->fetchAll($select) as $row) {
Expand Down Expand Up @@ -696,11 +711,10 @@ public function saveData()
$this->_productSuperData = [];
$this->_productData = null;

if ($this->_entityModel->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) {
$this->_loadSkuSuperData();
}

while ($bunch = $this->_entityModel->getNextBunch()) {
if ($this->_entityModel->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) {
$this->_loadSkuSuperDataForBunch($bunch);
}
if (!$this->configurableInBunch($bunch)) {
continue;
}
Expand Down

0 comments on commit 4923f81

Please sign in to comment.