/** * @magentoAppArea adminhtml * @magentoDbIsolation enabled * @magentoAppIsolation enabled */ public function testBundleImport() { // import data from CSV file $pathToFile = __DIR__ . '/../../_files/import_bundle.csv'; $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create(\Magento\ImportExport\Model\Import\Source\Csv::class, ['file' => $pathToFile, 'directory' => $directory]); $errors = $this->model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->validateData(); $this->assertTrue($errors->getErrorsCount() == 0); $this->model->importData(); $resource = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Product::class); $productId = $resource->getIdBySku(self::TEST_PRODUCT_NAME); $this->assertTrue(is_numeric($productId)); /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($productId); $this->assertFalse($product->isObjectNew()); $this->assertEquals(self::TEST_PRODUCT_NAME, $product->getName()); $this->assertEquals(self::TEST_PRODUCT_TYPE, $product->getTypeId()); $this->assertEquals(1, $product->getShipmentType()); $optionIdList = $resource->getProductsIdsBySkus($this->optionSkuList); $bundleOptionCollection = $product->getExtensionAttributes()->getBundleProductOptions(); $this->assertEquals(2, count($bundleOptionCollection)); foreach ($bundleOptionCollection as $optionKey => $option) { $this->assertEquals('checkbox', $option->getData('type')); $this->assertEquals('Option ' . ($optionKey + 1), $option->getData('title')); $this->assertEquals(self::TEST_PRODUCT_NAME, $option->getData('sku')); $this->assertEquals($optionKey + 1, count($option->getData('product_links'))); foreach ($option->getData('product_links') as $linkKey => $productLink) { $optionSku = 'Simple ' . ($optionKey + 1 + $linkKey); $this->assertEquals($optionIdList[$optionSku], $productLink->getData('entity_id')); $this->assertEquals($optionSku, $productLink->getData('sku')); } } }
/** * @param string $behavior * @param array $attrParams * @param array $rowData * @param bool $isValid * @param string $attrCode * @dataProvider attributeValidationProvider */ public function testAttributeValidation($behavior, $attrParams, $rowData, $isValid, $attrCode = 'attribute_code') { $this->context->expects($this->any())->method('getBehavior')->willReturn($behavior); $result = $this->validator->isAttributeValid($attrCode, $attrParams, $rowData); $this->assertEquals($isValid, $result); if (!$isValid) { $this->assertTrue($this->validator->hasMessages()); } }
/** * @param ImportProduct $import * @return void */ protected function clearProductUrls(ImportProduct $import) { $oldSku = $import->getOldSku(); while ($bunch = $import->getNextBunch()) { $idToDelete = []; foreach ($bunch as $rowNum => $rowData) { if ($import->validateRow($rowData, $rowNum) && ImportProduct::SCOPE_DEFAULT == $import->getRowScope($rowData)) { $idToDelete[] = $oldSku[$rowData[ImportProduct::COL_SKU]]['entity_id']; } } foreach ($idToDelete as $productId) { $this->urlPersist->deleteByData([UrlRewrite::ENTITY_ID => $productId, UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE]); } } }
/** * @magentoDataFixture Magento/AdvancedPricingImportExport/_files/create_products.php * @magentoAppArea adminhtml */ public function testImportReplace() { // import data from CSV file $pathToFile = __DIR__ . '/_files/import_advanced_pricing.csv'; $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create(\Magento\ImportExport\Model\Import\Source\Csv::class, ['file' => $pathToFile, 'directory' => $directory]); $errors = $this->model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE, 'entity' => 'advanced_pricing'])->validateData(); $this->assertEquals(0, $errors->getErrorsCount(), 'Advanced pricing import validation error'); $this->model->importData(); /** @var \Magento\Catalog\Model\ResourceModel\Product $resource */ $resource = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Product::class); $productIdList = $resource->getProductsIdsBySkus(array_keys($this->expectedTierPrice)); /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); foreach ($productIdList as $sku => $productId) { $product->load($productId); $tierPriceCollection = $product->getTierPrices(); $this->assertEquals(3, count($tierPriceCollection)); /** @var \Magento\Catalog\Model\Product\TierPrice $tierPrice */ foreach ($tierPriceCollection as $tierPrice) { $this->assertContains($tierPrice->getData(), $this->expectedTierPrice[$sku]); } } }
/** * Test for afterImportData() * Covers afterImportData() + protected methods used inside except related to generateUrls() ones. * generateUrls will be covered separately. * * @covers \Magento\CatalogUrlRewrite\Model\Product\Plugin\Import::afterImportData * @covers \Magento\CatalogUrlRewrite\Model\Product\Plugin\Import::_populateForUrlGeneration * @covers \Magento\CatalogUrlRewrite\Model\Product\Plugin\Import::isGlobalScope * @covers \Magento\CatalogUrlRewrite\Model\Product\Plugin\Import::populateGlobalProduct * @covers \Magento\CatalogUrlRewrite\Model\Product\Plugin\Import::addProductToImport * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testAfterImportData() { $newSku = ['entity_id' => 'value']; $websiteId = 'websiteId value'; $productsCount = count($this->products); $websiteMock = $this->getMock('\\Magento\\Store\\Model\\Website', ['getStoreIds'], [], '', false); $storeIds = [1, Store::DEFAULT_STORE_ID]; $websiteMock->expects($this->once())->method('getStoreIds')->willReturn($storeIds); $this->storeManager->expects($this->once())->method('getWebsite')->with($websiteId)->willReturn($websiteMock); $this->importProduct->expects($this->exactly($productsCount))->method('getNewSku')->withConsecutive([$this->products[0][ImportProduct::COL_SKU]], [$this->products[1][ImportProduct::COL_SKU]])->willReturn($newSku); $this->importProduct->expects($this->exactly($productsCount))->method('getProductCategories')->withConsecutive([$this->products[0][ImportProduct::COL_SKU]], [$this->products[1][ImportProduct::COL_SKU]]); $getProductWebsitesCallsCount = $productsCount * 2; $this->importProduct->expects($this->exactly($getProductWebsitesCallsCount))->method('getProductWebsites')->willReturn([$newSku['entity_id'] => $websiteId]); $map = [[$this->products[0][ImportProduct::COL_STORE], $this->products[0][ImportProduct::COL_STORE]], [$this->products[1][ImportProduct::COL_STORE], $this->products[1][ImportProduct::COL_STORE]]]; $this->importProduct->expects($this->exactly(1))->method('getStoreIdByCode')->will($this->returnValueMap($map)); $product = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getId', 'setId', 'getSku', 'setStoreId', 'getStoreId'], [], '', false); $product->expects($this->exactly($productsCount))->method('setId')->with($newSku['entity_id']); $product->expects($this->any())->method('getId')->willReturn($newSku['entity_id']); $product->expects($this->exactly($productsCount))->method('getSku')->will($this->onConsecutiveCalls($this->products[0]['sku'], $this->products[1]['sku'])); $product->expects($this->exactly($productsCount))->method('getStoreId')->will($this->onConsecutiveCalls($this->products[0][ImportProduct::COL_STORE], $this->products[1][ImportProduct::COL_STORE])); $product->expects($this->once())->method('setStoreId')->with($this->products[1][ImportProduct::COL_STORE]); $this->catalogProductFactory->expects($this->exactly($productsCount))->method('create')->willReturn($product); $this->connection->expects($this->exactly(4))->method('quoteInto')->withConsecutive(['(store_id = ?', $storeIds[0]], [' AND entity_id = ?)', $newSku['entity_id']]); $productUrls = ['url 1', 'url 2']; $importMock = $this->getImportMock(['generateUrls', 'canonicalUrlRewriteGenerate', 'categoriesUrlRewriteGenerate', 'currentUrlRewritesRegenerate', 'cleanOverriddenUrlKey']); $importMock->expects($this->once())->method('generateUrls')->willReturn($productUrls); $this->urlPersist->expects($this->once())->method('replace')->with($productUrls); $importMock->afterImportData($this->observer); }
public function testIsRowValidError() { $rowData = ['_attribute_set' => 'attribute_set_name']; $rowNum = 1; $this->entityModel->expects($this->any())->method('getRowScope')->willReturn(1); $this->entityModel->expects($this->once())->method('addRowError')->with(\Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface::ERROR_VALUE_IS_REQUIRED, 1, 'attr_code')->willReturnSelf(); $this->assertFalse($this->simpleType->isRowValid($rowData, $rowNum)); }
/** * @magentoDataFixture Magento/Store/_files/website.php * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php * @magentoAppIsolation enabled */ public function testValidateUrlKeysMultipleStores() { $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem'); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create('\\Magento\\ImportExport\\Model\\Import\\Source\\Csv', ['file' => __DIR__ . '/_files/products_to_check_valid_url_keys_multiple_stores.csv', 'directory' => $directory]); $errors = $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->setSource($source)->validateData(); $this->assertTrue($errors->getErrorsCount() == 0); }
/** * @param UrlRewrite $url * @return Category|null|bool */ protected function retrieveCategoryFromMetadata($url) { $metadata = $url->getMetadata(); if (isset($metadata['category_id'])) { $category = $this->import->getCategoryProcessor()->getCategoryById($metadata['category_id']); return $category === null ? false : $category; } return null; }
/** * @magentoDbIsolation enabled */ public function testProductWithInvalidWeight() { // import data from CSV file $pathToFile = __DIR__ . '/_files/product_to_import_invalid_weight.csv'; $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem'); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = new \Magento\ImportExport\Model\Import\Source\Csv($pathToFile, $directory); $validationResult = $this->_model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND])->isDataValid(); $expectedErrors = ["Product weight is invalid" => [2]]; $this->assertFalse($validationResult); $this->assertEquals($expectedErrors, $this->_model->getErrorMessages()); }
public function testSaveData() { $this->_entityModel->expects($this->any())->method('getNewSku')->will($this->returnValue(['configurableskuI22' => ['entity_id' => 1, 'type_id' => 'configurable', 'attr_set_code' => 'Default'], 'testconf2-attr2val1-testattr3v1' => ['entity_id' => 2, 'type_id' => 'simple', 'attr_set_code' => 'Default'], 'testconf2-attr2val1-testattr30v1' => ['entity_id' => 20, 'type_id' => 'simple', 'attr_set_code' => 'Default'], 'testconf2-attr2val1-testattr3v2' => ['entity_id' => 3, 'type_id' => 'simple', 'attr_set_code' => 'Default'], 'testSimple' => ['entity_id' => 4, 'type_id' => 'simple', 'attr_set_code' => 'Default'], 'testSimpleToSkip' => ['entity_id' => 5, 'type_id' => 'simple', 'attr_set_code' => 'Default'], 'configurableskuI22withoutLabels' => ['entity_id' => 6, 'type_id' => 'configurable', 'attr_set_code' => 'Default'], 'configurableskuI22withoutVariations' => ['entity_id' => 7, 'type_id' => 'configurable', 'attr_set_code' => 'Default'], 'configurableskuI22Duplicated' => ['entity_id' => 8, 'type_id' => 'configurable', 'attr_set_code' => 'Default'], 'configurableskuI22BadPrice' => ['entity_id' => 9, 'type_id' => 'configurable', 'attr_set_code' => 'Default']])); $this->_connection->expects($this->any())->method('select')->will($this->returnValue($this->select)); $this->_connection->expects($this->any())->method('fetchAll')->with($this->select)->will($this->returnValue([['attribute_id' => 131, 'product_id' => 1, 'option_id' => 1, 'product_super_attribute_id' => 131], ['attribute_id' => 131, 'product_id' => 2, 'option_id' => 1, 'product_super_attribute_id' => 131], ['attribute_id' => 131, 'product_id' => 2, 'option_id' => 2, 'product_super_attribute_id' => 131], ['attribute_id' => 131, 'product_id' => 2, 'option_id' => 3, 'product_super_attribute_id' => 131], ['attribute_id' => 131, 'product_id' => 20, 'option_id' => 1, 'product_super_attribute_id' => 131], ['attribute_id' => 131, 'product_id' => 20, 'option_id' => 2, 'product_super_attribute_id' => 131], ['attribute_id' => 131, 'product_id' => 20, 'option_id' => 3, 'product_super_attribute_id' => 131], ['attribute_id' => 132, 'product_id' => 1, 'option_id' => 1, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 1, 'option_id' => 2, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 1, 'option_id' => 3, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 1, 'option_id' => 4, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 1, 'option_id' => 5, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 1, 'option_id' => 6, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 3, 'option_id' => 3, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 4, 'option_id' => 4, 'product_super_attribute_id' => 132], ['attribute_id' => 132, 'product_id' => 5, 'option_id' => 5, 'product_super_attribute_id' => 132]])); $this->_connection->expects($this->any())->method('fetchAll')->with($this->select)->will($this->returnValue([])); $bunch = $this->_getBunch(); $this->_entityModel->expects($this->at(2))->method('getNextBunch')->will($this->returnValue($bunch)); $this->_entityModel->expects($this->at(3))->method('getNextBunch')->will($this->returnValue([])); $this->_entityModel->expects($this->any())->method('isRowAllowedToImport')->will($this->returnCallback([$this, 'isRowAllowedToImport'])); $this->_entityModel->expects($this->any())->method('getOldSku')->will($this->returnValue(['testSimpleOld' => ['entity_id' => 10, 'type_id' => 'simple', 'attr_set_code' => 'Default']])); $this->_entityModel->expects($this->any())->method('getAttrSetIdToName')->willReturn([4 => 'Default']); $this->configurable->saveData(); }
/** * Test saveData() with store row scope */ public function testSaveDataScopeStore() { $this->entityModel->expects($this->once())->method('getNewSku')->will($this->returnValue(['sku_assoc1' => ['entity_id' => 1], 'productSku' => ['entity_id' => 2, 'attr_set_code' => 'Default', 'type_id' => 'grouped']])); $this->entityModel->expects($this->once())->method('getOldSku')->will($this->returnValue(['sku_assoc2' => ['entity_id' => 3]])); $attributes = ['position' => ['id' => 0], 'qty' => ['id' => 0]]; $this->links->expects($this->once())->method('getAttributes')->will($this->returnValue($attributes)); $bunch = [['associated_skus' => 'sku_assoc1=1, sku_assoc2=2', 'sku' => 'productSku', 'product_type' => 'grouped']]; $this->entityModel->expects($this->at(2))->method('getNextBunch')->will($this->returnValue($bunch)); $this->entityModel->expects($this->any())->method('isRowAllowedToImport')->will($this->returnValue(true)); $this->entityModel->expects($this->at(4))->method('getRowScope')->will($this->returnValue(\Magento\CatalogImportExport\Model\Import\Product::SCOPE_DEFAULT)); $this->entityModel->expects($this->at(5))->method('getRowScope')->will($this->returnValue(\Magento\CatalogImportExport\Model\Import\Product::SCOPE_STORE)); $this->links->expects($this->once())->method('saveLinksData'); $this->grouped->saveData(); }
/** * @dataProvider dataForUploaderDir */ public function testSetUploaderDirFalse($newSku, $bunch, $allowImport) { $this->connectionMock->expects($this->any())->method('fetchAll')->with($this->select)->willReturnOnConsecutiveCalls([['attribute_set_name' => '1', 'attribute_id' => '1'], ['attribute_set_name' => '2', 'attribute_id' => '2']]); $this->downloadableModelMock = $this->objectManagerHelper->getObject('\\Magento\\DownloadableImportExport\\Model\\Import\\Product\\Type\\Downloadable', ['attrSetColFac' => $this->attrSetColFacMock, 'prodAttrColFac' => $this->prodAttrColFacMock, 'resource' => $this->resourceMock, 'params' => $this->paramsArray, 'uploaderHelper' => $this->uploaderHelper, 'downloadableHelper' => $this->downloadableHelper]); $this->entityModelMock->expects($this->once())->method('getNewSku')->will($this->returnValue($newSku)); $this->entityModelMock->expects($this->at(1))->method('getNextBunch')->will($this->returnValue($bunch)); $this->entityModelMock->expects($this->at(2))->method('getNextBunch')->will($this->returnValue(null)); $this->entityModelMock->expects($this->any())->method('isRowAllowedToImport')->willReturn($allowImport); $exception = new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Error')); $this->setExpectedException('\\Magento\\Framework\\Exception\\LocalizedException'); $this->setExpectedException('\\Exception'); $this->uploaderMock->expects($this->any())->method('move')->will($this->throwException($exception)); $this->downloadableModelMock->saveData(); }
/** * @magentoAppArea adminhtml * @magentoDbIsolation enabled * @magentoAppIsolation enabled */ public function testImport() { // Import data from CSV file $pathToFile = __DIR__ . '/../../_files/grouped_product.csv'; $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create(\Magento\ImportExport\Model\Import\Source\Csv::class, ['file' => $pathToFile, 'directory' => $directory]); $errors = $this->model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->validateData(); $this->assertTrue($errors->getErrorsCount() == 0); $this->model->importData(); $resource = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Product::class); $productId = $resource->getIdBySku('Test Grouped'); $this->assertTrue(is_numeric($productId)); /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($productId); $this->assertFalse($product->isObjectNew()); $this->assertEquals(self::TEST_PRODUCT_NAME, $product->getName()); $this->assertEquals(self::TEST_PRODUCT_TYPE, $product->getTypeId()); $childProductCollection = $product->getTypeInstance()->getAssociatedProducts($product); foreach ($childProductCollection as $childProduct) { $this->assertContains($childProduct->getSku(), $this->optionSkuList); } }
/** * @magentoAppIsolation enabled */ public function testProductWithUseConfigSettings() { $products = ['simple1' => true, 'simple2' => true, 'simple3' => false]; $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem'); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create('\\Magento\\ImportExport\\Model\\Import\\Source\\Csv', ['file' => __DIR__ . '/_files/products_to_import_with_use_config_settings.csv', 'directory' => $directory]); $errors = $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->setSource($source)->validateData(); $this->assertTrue($errors->getErrorsCount() == 0); $this->_model->importData(); foreach ($products as $sku => $manageStockUseConfig) { /** @var \Magento\CatalogInventory\Model\StockRegistry $stockRegistry */ $stockRegistry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogInventory\\Model\\StockRegistry'); $stockItem = $stockRegistry->getStockItemBySku($sku); $this->assertEquals($manageStockUseConfig, $stockItem->getUseConfigManageStock()); } }
/** * Test for validation of ambiguous data * * @param array $rowData * @param array $errors * @param string|null $behavior * @param int $numberOfValidations * * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::validateAmbiguousData * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findOldOptionsWithTheSameTitles * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_findNewOldOptionsTypeMismatch * @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_saveNewOptionData * @dataProvider validateAmbiguousDataDataProvider */ public function testValidateAmbiguousData(array $rowData, array $errors, $behavior = null, $numberOfValidations = 1) { $this->_testStores = ['admin' => 0]; $this->setUp(); if ($behavior) { $this->_modelMock->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND]); } $this->_bypassModelMethodGetMultiRowFormat($rowData); for ($i = 0; $i < $numberOfValidations; $i++) { $this->_modelMock->validateRow($rowData, $i); } if (empty($errors)) { $this->assertTrue($this->_modelMock->validateAmbiguousData()); } else { $this->assertFalse($this->_modelMock->validateAmbiguousData()); } $resultErrors = $this->_productEntity->getErrorAggregator()->getRowsGroupedByErrorCode([], [], false); $this->assertEquals($errors, $resultErrors); }
/** * Test for afterImportData() * Covers afterImportData() + protected methods used inside * * @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::afterImportData * @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::_populateForUrlGeneration * @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::isGlobalScope * @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::populateGlobalProduct * @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::addProductToImport * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testAfterImportData() { $newSku = [['entity_id' => 'value'], ['entity_id' => 'value3']]; $websiteId = 'websiteId value'; $productsCount = count($this->products); $websiteMock = $this->getMock('\\Magento\\Store\\Model\\Website', ['getStoreIds'], [], '', false); $storeIds = [1, Store::DEFAULT_STORE_ID]; $websiteMock->expects($this->once())->method('getStoreIds')->willReturn($storeIds); $this->storeManager->expects($this->once())->method('getWebsite')->with($websiteId)->willReturn($websiteMock); $this->importProduct->expects($this->exactly($productsCount))->method('getNewSku')->withConsecutive([$this->products[0][ImportProduct::COL_SKU]], [$this->products[1][ImportProduct::COL_SKU]])->will($this->onConsecutiveCalls($newSku[0], $newSku[1])); $this->importProduct->expects($this->exactly($productsCount))->method('getProductCategories')->withConsecutive([$this->products[0][ImportProduct::COL_SKU]], [$this->products[1][ImportProduct::COL_SKU]])->willReturn([]); $getProductWebsitesCallsCount = $productsCount * 2; $this->importProduct->expects($this->exactly($getProductWebsitesCallsCount))->method('getProductWebsites')->willReturnOnConsecutiveCalls([$newSku[0]['entity_id'] => $websiteId], [$newSku[0]['entity_id'] => $websiteId], [$newSku[1]['entity_id'] => $websiteId], [$newSku[1]['entity_id'] => $websiteId]); $map = [[$this->products[0][ImportProduct::COL_STORE], $this->products[0][ImportProduct::COL_STORE]], [$this->products[1][ImportProduct::COL_STORE], $this->products[1][ImportProduct::COL_STORE]]]; $this->importProduct->expects($this->exactly(1))->method('getStoreIdByCode')->will($this->returnValueMap($map)); $product = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getId', 'setId', 'getSku', 'setStoreId', 'getStoreId'], [], '', false); $product->expects($this->exactly($productsCount))->method('setId')->withConsecutive([$newSku[0]['entity_id']], [$newSku[1]['entity_id']]); $product->expects($this->any())->method('getId')->willReturnOnConsecutiveCalls($newSku[0]['entity_id'], $newSku[0]['entity_id'], $newSku[0]['entity_id'], $newSku[0]['entity_id'], $newSku[0]['entity_id'], $newSku[1]['entity_id'], $newSku[1]['entity_id'], $newSku[1]['entity_id']); $product->expects($this->exactly($productsCount))->method('getSku')->will($this->onConsecutiveCalls($this->products[0]['sku'], $this->products[1]['sku'])); $product->expects($this->exactly($productsCount))->method('getStoreId')->will($this->onConsecutiveCalls($this->products[0][ImportProduct::COL_STORE], $this->products[1][ImportProduct::COL_STORE])); $product->expects($this->exactly($productsCount))->method('setStoreId')->withConsecutive([$this->products[0][ImportProduct::COL_STORE]], [$this->products[1][ImportProduct::COL_STORE]]); $this->catalogProductFactory->expects($this->exactly($productsCount))->method('create')->willReturn($product); $this->connection->expects($this->exactly(4))->method('quoteInto')->withConsecutive(['(store_id = ?', $storeIds[0]], [' AND entity_id = ?)', $newSku[0]['entity_id']], ['(store_id = ?', $storeIds[0]], [' AND entity_id = ?)', $newSku[1]['entity_id']]); $this->connection->expects($this->once())->method('fetchAll')->willReturn([]); $this->select->expects($this->any())->method('from')->willReturnSelf(); $this->select->expects($this->any())->method('where')->willReturnSelf(); $this->urlFinder->expects($this->any())->method('findAllByData')->willReturn([]); $this->productUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')->willReturn('urlPathWithSuffix'); $this->productUrlPathGenerator->expects($this->any())->method('getUrlPath')->willReturn('urlPath'); $this->productUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')->willReturn('canonicalUrlPath'); $this->urlRewrite->expects($this->any())->method('setStoreId')->willReturnSelf(); $this->urlRewrite->expects($this->any())->method('setEntityId')->willReturnSelf(); $this->urlRewrite->expects($this->any())->method('setEntityType')->willReturnSelf(); $this->urlRewrite->expects($this->any())->method('setRequestPath')->willReturnSelf(); $this->urlRewrite->expects($this->any())->method('setTargetPath')->willReturnSelf(); $this->urlRewrite->expects($this->any())->method('getTargetPath')->willReturn('targetPath'); $this->urlRewrite->expects($this->any())->method('getStoreId')->willReturnOnConsecutiveCalls(0, 'not global'); $this->urlRewriteFactory->expects($this->any())->method('create')->willReturn($this->urlRewrite); $productUrls = ['targetPath-0' => $this->urlRewrite, 'targetPath-not global' => $this->urlRewrite]; $this->urlPersist->expects($this->once())->method('replace')->with($productUrls); $this->import->execute($this->observer); }
/** * @return bool * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ protected function isValidAttributes() { $this->_clearMessages(); if (!isset($this->_rowData['product_type'])) { return false; } $entityTypeModel = $this->context->retrieveProductTypeByName($this->_rowData['product_type']); if ($entityTypeModel) { foreach ($this->_rowData as $attrCode => $attrValue) { $attrParams = $entityTypeModel->retrieveAttributeFromCache($attrCode); if ($attrParams) { $this->isAttributeValid($attrCode, $attrParams, $this->_rowData); } } if ($this->getMessages()) { return false; } } return true; }
public function testSaveData() { $associatedSku = 'sku_assoc'; $productSku = 'productSku'; $this->entityModel->expects($this->once())->method('getNewSku')->will($this->returnValue([$associatedSku => ['entity_id' => 1], $productSku => ['entity_id' => 2]])); $attributes = ['position' => ['id' => 0], 'qty' => ['id' => 0]]; $this->links->expects($this->once())->method('getAttributes')->will($this->returnValue($attributes)); $bunch = [['_associated_sku' => $associatedSku, 'sku' => $productSku, '_type' => 'grouped', '_associated_default_qty' => 4, '_associated_position' => 6]]; $this->entityModel->expects($this->at(0))->method('getNextBunch')->will($this->returnValue($bunch)); $this->entityModel->expects($this->at(1))->method('getNextBunch')->will($this->returnValue($bunch)); $this->entityModel->expects($this->any())->method('isRowAllowedToImport')->will($this->returnValue(true)); $this->entityModel->expects($this->any())->method('getRowScope')->will($this->returnValue(\Magento\CatalogImportExport\Model\Import\Product::SCOPE_DEFAULT)); $this->links->expects($this->once())->method("saveLinksData"); $this->grouped->saveData(); }
/** * @magentoDataFixture Magento/Catalog/_files/categories.php * @magentoDataFixture Magento/Core/_files/store.php * @magentoDataFixture Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php */ public function testProductsWithMultipleStores() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $filesystem = $objectManager->create('Magento\\Framework\\App\\Filesystem'); $directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR); $source = new \Magento\ImportExport\Model\Import\Source\Csv(__DIR__ . '/_files/products_multiple_stores.csv', $directory); $this->_model->setParameters(array('behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'))->setSource($source)->isDataValid(); $this->_model->importData(); /** @var \Magento\Catalog\Model\Product $product */ $product = $objectManager->create('Magento\\Catalog\\Model\\Product'); $id = $product->getIdBySku('Configurable 03'); $product->load($id); $this->assertEquals('1', $product->getHasOptions()); $objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->setCurrentStore('fixturestore'); /** @var \Magento\Catalog\Model\Product $simpleProduct */ $simpleProduct = $objectManager->create('Magento\\Catalog\\Model\\Product'); $id = $simpleProduct->getIdBySku('Configurable 03-option_0'); $simpleProduct->load($id); $this->assertEquals('Option Label', $simpleProduct->getAttributeText('attribute_with_option')); $this->assertEquals(array(2, 4), $simpleProduct->getAvailableInCategories()); }
/** * @magentoAppArea adminhtml * @dataProvider categoryTestDataProvider * @magentoDbIsolation enabled * @magentoAppIsolation enabled */ public function testProductCategories($fixture, $separator) { // import data from CSV file $pathToFile = __DIR__ . '/_files/' . $fixture; $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem'); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = new \Magento\ImportExport\Model\Import\Source\Csv($pathToFile, $directory); $errors = $this->_model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product', Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR => $separator])->validateData(); $this->assertTrue($errors->getErrorsCount() == 0); $this->_model->importData(); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $resource = $objectManager->get('Magento\\Catalog\\Model\\ResourceModel\\Product'); $productId = $resource->getIdBySku('simple1'); $this->assertTrue(is_numeric($productId)); /** @var \Magento\Catalog\Model\Product $product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->load($productId); $this->assertFalse($product->isObjectNew()); $categories = $product->getCategoryIds(); $this->assertTrue(count($categories) == 2); }
/** * Validate row attributes. Pass VALID row data ONLY as argument. * * @param array $rowData * @param int $rowNum * @param bool $isNewProduct Optional * @return bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true) { $error = false; $rowScope = $this->_entityModel->getRowScope($rowData); if (\Magento\CatalogImportExport\Model\Import\Product::SCOPE_NULL != $rowScope) { foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) { // check value for non-empty in the case of required attribute? if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) { $error |= !$this->_entityModel->isAttributeValid($attrCode, $attrParams, $rowData, $rowNum); } elseif ($this->_isAttributeRequiredCheckNeeded($attrCode) && $attrParams['is_required']) { // For the default scope - if this is a new product or // for an old product, if the imported doc has the column present for the attrCode if (\Magento\CatalogImportExport\Model\Import\Product::SCOPE_DEFAULT == $rowScope && ($isNewProduct || array_key_exists($attrCode, $rowData))) { $this->_entityModel->addRowError(\Magento\CatalogImportExport\Model\Import\Product::ERROR_VALUE_IS_REQUIRED, $rowNum, $attrCode); $error = true; } } } } $error |= !$this->_isParticularAttributesValid($rowData, $rowNum); return !$error; }
public function testValidateDefaultScopeNotValidAttributesResetSku() { $sku = 'sku'; $rowNum = 0; $attrCode = 'code'; $stringUtilsMock = $this->getMockBuilder('\\Magento\\Framework\\Stdlib\\StringUtils')->setMethods(null)->getMock(); $this->setPropertyValue($this->importProduct, 'string', $stringUtilsMock); $scopeMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', ['getRowScope'], [], '', false); $colStore = \Magento\CatalogImportExport\Model\Import\Product::COL_STORE; $scopeRowData = [$sku => 'sku', $colStore => null]; $scopeResult = \Magento\CatalogImportExport\Model\Import\Product::SCOPE_DEFAULT; $scopeMock->expects($this->any())->method('getRowScope')->with($scopeRowData)->willReturn($scopeResult); $oldSku = [$sku => ['type_id' => 'type_id_val']]; $this->setPropertyValue($this->importProduct, '_oldSku', $oldSku); $expectedSku = false; $newSku = ['attr_set_code' => 'new_attr_set_code', 'type_id' => 'new_type_id_val']; $this->skuProcessor->expects($this->any())->method('getNewSku')->with($expectedSku)->willReturn($newSku); $this->setPropertyValue($this->importProduct, 'skuProcessor', $this->skuProcessor); $attrParams = ['type' => 'varchar']; $attrRowData = ['code' => str_repeat('a', \Magento\CatalogImportExport\Model\Import\Product::DB_MAX_VARCHAR_LENGTH + 1)]; $this->validator->expects($this->once())->method('isAttributeValid')->willReturn(false); $messages = ['validator message']; $this->validator->expects($this->once())->method('getMessages')->willReturn($messages); $result = $this->importProduct->isAttributeValid($attrCode, $attrParams, $attrRowData, $rowNum); $this->assertFalse($result); }
/** * @magentoAppArea adminhtml * @magentoDbIsolation enabled * @magentoAppIsolation enabled * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testDownloadableImport() { // import data from CSV file $pathToFile = __DIR__ . '/../../_files/import_downloadable.csv'; $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create(\Magento\ImportExport\Model\Import\Source\Csv::class, ['file' => $pathToFile, 'directory' => $directory]); $errors = $this->model->setSource($source)->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'])->validateData(); $this->assertTrue($errors->getErrorsCount() == 0); $this->model->importData(); $resource = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Product::class); $productId = $resource->getIdBySku(self::TEST_PRODUCT_NAME); $this->assertTrue(is_numeric($productId)); /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); $product->load($productId); $this->assertFalse($product->isObjectNew()); $this->assertEquals(self::TEST_PRODUCT_NAME, $product->getName()); $this->assertEquals(self::TEST_PRODUCT_TYPE, $product->getTypeId()); $downloadableProductLinks = $product->getExtensionAttributes()->getDownloadableProductLinks(); $downloadableLinks = $product->getDownloadableLinks(); $downloadableProductSamples = $product->getExtensionAttributes()->getDownloadableProductSamples(); $downloadableSamples = $product->getDownloadableSamples(); //TODO: Track Fields: id, link_id, link_file and sample_file) $expectedLinks = ['file' => ['title' => 'TEST Import Link Title File', 'sort_order' => '78', 'sample_type' => 'file', 'price' => '123.0000', 'number_of_downloads' => '123', 'is_shareable' => '0', 'link_type' => 'file'], 'url' => ['title' => 'TEST Import Link Title URL', 'sort_order' => '42', 'sample_type' => 'url', 'sample_url' => 'http://www.bing.com', 'price' => '1.0000', 'number_of_downloads' => '0', 'is_shareable' => '1', 'link_type' => 'url', 'link_url' => 'http://www.google.com']]; foreach ($downloadableProductLinks as $link) { $actualLink = $link->getData(); $this->assertArrayHasKey('link_type', $actualLink); foreach ($expectedLinks[$actualLink['link_type']] as $expectedKey => $expectedValue) { $this->assertArrayHasKey($expectedKey, $actualLink); $this->assertEquals($actualLink[$expectedKey], $expectedValue); } } foreach ($downloadableLinks as $link) { $actualLink = $link->getData(); $this->assertArrayHasKey('link_type', $actualLink); $this->assertArrayHasKey('product_id', $actualLink); $this->assertEquals($actualLink['product_id'], $product->getData($this->productMetadata->getLinkField())); foreach ($expectedLinks[$actualLink['link_type']] as $expectedKey => $expectedValue) { $this->assertArrayHasKey($expectedKey, $actualLink); $this->assertEquals($actualLink[$expectedKey], $expectedValue); } } //TODO: Track Fields: id, sample_id and sample_file) $expectedSamples = ['file' => ['title' => 'TEST Import Sample File', 'sort_order' => '178', 'sample_type' => 'file'], 'url' => ['title' => 'TEST Import Sample URL', 'sort_order' => '178', 'sample_type' => 'url', 'sample_url' => 'http://www.yahoo.com']]; foreach ($downloadableProductSamples as $sample) { $actualSample = $sample->getData(); $this->assertArrayHasKey('sample_type', $actualSample); foreach ($expectedSamples[$actualSample['sample_type']] as $expectedKey => $expectedValue) { $this->assertArrayHasKey($expectedKey, $actualSample); $this->assertEquals($actualSample[$expectedKey], $expectedValue); } } foreach ($downloadableSamples as $sample) { $actualSample = $sample->getData(); $this->assertArrayHasKey('sample_type', $actualSample); $this->assertArrayHasKey('product_id', $actualSample); $this->assertEquals($actualSample['product_id'], $product->getData($this->productMetadata->getLinkField())); foreach ($expectedSamples[$actualSample['sample_type']] as $expectedKey => $expectedValue) { $this->assertArrayHasKey($expectedKey, $actualSample); $this->assertEquals($actualSample[$expectedKey], $expectedValue); } } }
/** * Test for isRowValid() */ public function testIsRowValid() { $this->entityModel->expects($this->any())->method('getRowScope')->will($this->returnValue(-1)); $rowData = ['bundle_price_type' => 'dynamic', 'bundle_price_view' => 'bundle_price_view']; $this->assertEquals($this->bundle->isRowValid($rowData, 0), true); }
/** * Parse custom options string to inner format. * * @param array $rowData * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _parseCustomOptions($rowData) { $beforeOptionValueSkuDelimiter = ';'; if (empty($rowData['custom_options'])) { return $rowData; } $rowData['custom_options'] = str_replace($beforeOptionValueSkuDelimiter, $this->_productEntity->getMultipleValueSeparator(), $rowData['custom_options']); $options = []; $optionValues = explode(Product::PSEUDO_MULTI_LINE_SEPARATOR, $rowData['custom_options']); $k = 0; $name = ''; foreach ($optionValues as $optionValue) { $optionValueParams = explode($this->_productEntity->getMultipleValueSeparator(), $optionValue); foreach ($optionValueParams as $nameAndValue) { $nameAndValue = explode('=', $nameAndValue); if (!empty($nameAndValue)) { $value = isset($nameAndValue[1]) ? $nameAndValue[1] : ''; $value = trim($value); $fieldName = trim($nameAndValue[0]); if ($value && $fieldName == 'name') { if ($name != $value) { $name = $value; $k = 0; } } if ($name) { $options[$name][$k][$fieldName] = $value; } } } $options[$name][$k]['_custom_option_store'] = $rowData[Product::COL_STORE_VIEW_CODE]; $k++; } $rowData['custom_options'] = $options; return $rowData; }
public function __construct(\Magento\Framework\App\Request\Http $request, \Firebear\ImportExport\Helper\Data $helper, \Magento\Framework\Json\Helper\Data $jsonHelper, \Magento\ImportExport\Helper\Data $importExportData, \Magento\ImportExport\Model\ResourceModel\Import\Data $importData, \Magento\Eav\Model\Config $config, \Magento\Framework\App\ResourceConnection $resource, \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Stdlib\StringUtils $string, \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface $errorAggregator, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider, \Magento\Catalog\Helper\Data $catalogData, \Magento\ImportExport\Model\Import\Config $importConfig, \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory $resourceFactory, \Magento\CatalogImportExport\Model\Import\Product\OptionFactory $optionFactory, \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory, \Magento\CatalogImportExport\Model\Import\Product\Type\Factory $productTypeFactory, \Magento\Catalog\Model\ResourceModel\Product\LinkFactory $linkFactory, \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory $proxyProdFactory, \Magento\CatalogImportExport\Model\Import\UploaderFactory $uploaderFactory, \Magento\Framework\Filesystem $filesystem, \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory $stockResItemFac, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, DateTime $dateTime, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\CatalogImportExport\Model\Import\Product\StoreResolver $storeResolver, \Magento\CatalogImportExport\Model\Import\Product\SkuProcessor $skuProcessor, \Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor $categoryProcessor, \Magento\CatalogImportExport\Model\Import\Product\Validator $validator, ObjectRelationProcessor $objectRelationProcessor, TransactionManagerInterface $transactionManager, \Magento\CatalogImportExport\Model\Import\Product\TaxClassProcessor $taxClassProcessor, \Magento\Framework\Model\Entity\MetadataPool $metadataPool, array $data = []) { $this->_request = $request; $this->_helper = $helper; parent::__construct($jsonHelper, $importExportData, $importData, $config, $resource, $resourceHelper, $string, $errorAggregator, $eventManager, $stockRegistry, $stockConfiguration, $stockStateProvider, $catalogData, $importConfig, $resourceFactory, $optionFactory, $setColFactory, $productTypeFactory, $linkFactory, $proxyProdFactory, $uploaderFactory, $filesystem, $stockResItemFac, $localeDate, $dateTime, $logger, $indexerRegistry, $storeResolver, $skuProcessor, $categoryProcessor, $validator, $objectRelationProcessor, $transactionManager, $taxClassProcessor, $metadataPool, $data); }
/** * Validate one specific parameter * * @param string $typeParameter * @param array $rowData * @param int $rowNumber * @return bool */ protected function _validateSpecificParameterData($typeParameter, array $rowData, $rowNumber) { $fieldName = self::COLUMN_PREFIX . $typeParameter; if ($typeParameter == 'price') { if (!empty($rowData[$fieldName]) && !is_numeric(rtrim($rowData[$fieldName], '%'))) { $this->_productEntity->addRowError(self::ERROR_INVALID_PRICE, $rowNumber); return false; } } elseif ($typeParameter == 'max_characters') { if (!empty($rowData[$fieldName]) && !ctype_digit((string) $rowData[$fieldName])) { $this->_productEntity->addRowError(self::ERROR_INVALID_MAX_CHARACTERS, $rowNumber); return false; } } return true; }
public function testPopulateToUrlGenerationReturnProduct() { $rowData = [\Magento\CatalogImportExport\Model\Import\Product::COL_SKU => 'value']; $newSku = ['entity_id' => 'new sku value']; $expectedRowData = [\Magento\CatalogImportExport\Model\Import\Product::COL_SKU => 'value', 'entity_id' => $newSku['entity_id']]; $productMock = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['addData'], [], '', false); $productMock->expects($this->once())->method('addData')->with($expectedRowData); $this->catalogProductFactory->expects($this->once())->method('create')->willReturn($productMock); $this->skuProcessor->expects($this->once())->method('getNewSku')->willReturn($newSku); $result = $this->importProduct->_populateToUrlGeneration($rowData); $this->assertEquals($productMock, $result); }
public function testIsBooleanAttributeValid() { $this->context->expects($this->any())->method('getBehavior')->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE); $result = $this->validator->isAttributeValid('boolean_attribute', ['type' => 'boolean', 'apply_to' => ['simple'], 'is_required' => false], ['product_type' => 'simple', 'boolean_attribute' => 'Yes']); $this->assertTrue($result); }
public function testValidateRowProcessEntityIncrement() { $count = 0; $rowNum = 0; $this->setPropertyValue($this->importProduct, '_processedEntitiesCount', $count); $rowData = [\Magento\CatalogImportExport\Model\Import\Product::COL_SKU => '']; //suppress validator $this->_setValidatorMockInImportProduct($this->importProduct); $this->importProduct->validateRow($rowData, $rowNum); $this->assertEquals(++$count, $this->importProduct->getProcessedEntitiesCount()); }