/** * Populate global product * * @param \Magento\Catalog\Model\Product $product * @return $this */ protected function populateGlobalProduct($product) { foreach ($this->import->getProductWebsites($product->getSku()) as $websiteId) { foreach ($this->websitesToStoreIds[$websiteId] as $storeId) { $this->storesCache[$storeId] = true; if (!$this->isGlobalScope($storeId)) { $this->addProductToImport($product, $storeId); } } } return $this; }
/** * Populate global product * * @param \Magento\CatalogImportExport\Model\Import\Product $product * @return $this */ protected function populateGlobalProduct($product) { foreach ($this->import->getProductWebsites($product->getSku()) as $websiteId) { foreach ($this->websitesToStoreIds[$websiteId] as $storeId) { $this->storesCache[$storeId] = true; if (!$this->isGlobalScope($storeId)) { $this->addProductToImport($product, $storeId); $this->entityStoresToCheckOverridden[] = $this->connection->quoteInto('(store_id = ?', $storeId) . $this->connection->quoteInto(' AND entity_id = ?)', $product->getId()); } } } return $this; }
/** * Cover getProductWebsites(). */ public function testGetProductWebsites() { $productSku = 'productSku'; $productValue = ['key 1' => 'val', 'key 2' => 'val', 'key 3' => 'val']; $expectedResult = array_keys($productValue); $this->setPropertyValue($this->importProduct, 'websitesCache', [$productSku => $productValue]); $actualResult = $this->importProduct->getProductWebsites($productSku); $this->assertEquals($expectedResult, $actualResult); }