Skip to content

Commit ea18e7d

Browse files
author
Yaroslav Onischenko
committed
MAGETWO-39795: Check data for import product does not work
MAGETWO-43900: Imported products with broken images link don't appear on front MAGETWO-43901: The "Imported resource (image) could not be downloaded" message appears when user tries to import products using "Replace" behavior MAGETWO-44238: Categories imported in a comma-separated format are not created properly MAGETWO-42245: _media_is_disabled is not exported MAGETWO-44407: CLONE - Product export and re-import with different store view level data causes data corruption
1 parent f4d3451 commit ea18e7d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,38 @@ protected function _populateForUrlGeneration($rowData)
190190
$product->setData($field, $rowData[$field]);
191191
}
192192
}
193+
193194
$this->categoryCache[$rowData['entity_id']] = $this->import->getProductCategories($rowData['sku']);
194195
$this->websiteCache[$rowData['entity_id']] = $this->import->getProductWebsites($rowData['sku']);
195196
foreach ($this->websiteCache[$rowData['entity_id']] as $websiteId) {
196197
if (!isset($this->websitesToStoreIds[$websiteId])) {
197198
$this->websitesToStoreIds[$websiteId] = $this->storeManager->getWebsite($websiteId)->getStoreIds();
198199
}
199200
}
201+
202+
$this->setStoreToProduct($product, $rowData);
203+
204+
if ($this->isGlobalScope($product->getStoreId())) {
205+
$this->populateGlobalProduct($product);
206+
} else {
207+
$this->addProductToImport($product, $product->getStoreId());
208+
}
209+
return $this;
210+
}
211+
212+
/**
213+
* @param \Magento\Catalog\Model\Product $product
214+
* @param array $rowData
215+
*/
216+
protected function setStoreToProduct(\Magento\Catalog\Model\Product $product, array $rowData)
217+
{
200218
if (!empty($rowData[ImportProduct::COL_STORE])
201219
&& ($storeId = $this->import->getStoreIdByCode($rowData[ImportProduct::COL_STORE]))
202220
) {
203221
$product->setStoreId($storeId);
204222
} elseif (!$product->hasData(\Magento\Catalog\Api\Data\ProductInterface::STORE_ID)) {
205223
$product->setStoreId(Store::DEFAULT_STORE_ID);
206224
}
207-
if ($this->isGlobalScope($product->getStoreId())) {
208-
$this->populateGlobalProduct($product);
209-
} else {
210-
$this->addProductToImport($product, $product->getStoreId());
211-
}
212-
return $this;
213225
}
214226

215227
/**

0 commit comments

Comments
 (0)