|
16 | 16 | use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
|
17 | 17 | use Magento\Catalog\Api\ProductRepositoryInterface;
|
18 | 18 | use Magento\Catalog\Model\Category;
|
| 19 | +use Magento\Catalog\Model\Product; |
| 20 | +use Magento\Catalog\Model\ResourceModel\Product as ProductResource; |
19 | 21 | use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface;
|
20 | 22 | use Magento\Framework\App\Bootstrap;
|
21 | 23 | use Magento\Framework\App\Filesystem\DirectoryList;
|
|
29 | 31 | use Magento\Store\Model\Store;
|
30 | 32 | use Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollection;
|
31 | 33 | use Psr\Log\LoggerInterface;
|
| 34 | +use Magento\TestFramework\Helper\Bootstrap as BootstrapHelper; |
32 | 35 |
|
33 | 36 | /**
|
34 | 37 | * Class ProductTest
|
@@ -312,7 +315,6 @@ public function testStockState()
|
312 | 315 | * @throws \Magento\Framework\Exception\LocalizedException
|
313 | 316 | * @throws \Magento\Framework\Exception\NoSuchEntityException
|
314 | 317 | * @magentoAppIsolation enabled
|
315 |
| -
|
316 | 318 | *
|
317 | 319 | * @return void
|
318 | 320 | */
|
@@ -1574,6 +1576,49 @@ public function testValidateUrlKeysMultipleStores()
|
1574 | 1576 | $this->assertTrue($errors->getErrorsCount() == 0);
|
1575 | 1577 | }
|
1576 | 1578 |
|
| 1579 | + /** |
| 1580 | + * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_product_links_data.php |
| 1581 | + * @magentoAppArea adminhtml |
| 1582 | + * @magentoDbIsolation enabled |
| 1583 | + * @magentoAppIsolation enabled |
| 1584 | + */ |
| 1585 | + public function testProductLinksWithEmptyValue() |
| 1586 | + { |
| 1587 | + // import data from CSV file |
| 1588 | + $pathToFile = __DIR__ . '/_files/products_to_import_with_product_links_with_empty_value.csv'; |
| 1589 | + $filesystem = BootstrapHelper::getObjectManager()->create(Filesystem::class); |
| 1590 | + |
| 1591 | + $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); |
| 1592 | + $source = $this->objectManager->create( |
| 1593 | + Csv::class, |
| 1594 | + [ |
| 1595 | + 'file' => $pathToFile, |
| 1596 | + 'directory' => $directory |
| 1597 | + ] |
| 1598 | + ); |
| 1599 | + $errors = $this->_model->setSource( |
| 1600 | + $source |
| 1601 | + )->setParameters( |
| 1602 | + [ |
| 1603 | + 'behavior' => Import::BEHAVIOR_APPEND, |
| 1604 | + 'entity' => 'catalog_product' |
| 1605 | + ] |
| 1606 | + )->validateData(); |
| 1607 | + |
| 1608 | + $this->assertTrue($errors->getErrorsCount() == 0); |
| 1609 | + $this->_model->importData(); |
| 1610 | + |
| 1611 | + $objectManager = BootstrapHelper::getObjectManager(); |
| 1612 | + $resource = $objectManager->get(ProductResource::class); |
| 1613 | + $productId = $resource->getIdBySku('simple'); |
| 1614 | + /** @var \Magento\Catalog\Model\Product $product */ |
| 1615 | + $product = BootstrapHelper::getObjectManager()->create(Product::class); |
| 1616 | + $product->load($productId); |
| 1617 | + |
| 1618 | + $this->assertEmpty($product->getCrossSellProducts()); |
| 1619 | + $this->assertEmpty($product->getUpSellProducts()); |
| 1620 | + } |
| 1621 | + |
1577 | 1622 | /**
|
1578 | 1623 | * @magentoAppArea adminhtml
|
1579 | 1624 | * @magentoDbIsolation enabled
|
|
0 commit comments