Skip to content

Commit ccd3987

Browse files
ENGCOM-4772: Don't skip row on import if image not available. #22382
- Merge Pull Request #22382 from Nazar65/magento2:issue-22355 - Merged commits: 1. e949e85
2 parents 88eba25 + e949e85 commit ccd3987

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,13 @@ protected function _saveProducts()
17981798
$uploadedImages[$columnImage] = $uploadedFile;
17991799
} else {
18001800
unset($rowData[$column]);
1801-
$this->skipRow($rowNum, ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE);
1801+
$this->addRowError(
1802+
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
1803+
$rowNum,
1804+
null,
1805+
null,
1806+
ProcessingError::ERROR_LEVEL_NOT_CRITICAL
1807+
);
18021808
}
18031809
} else {
18041810
$uploadedFile = $uploadedImages[$columnImage];

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,45 @@ public function testAddUpdateProductWithInvalidUrlKeys() : void
15901590
}
15911591
}
15921592

1593+
/**
1594+
* Make sure the non existing image in the csv file won't erase the qty key of the existing products.
1595+
*
1596+
* @magentoDataFixture Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_non_existing_image.csv
1597+
* @magentoDbIsolation enabled
1598+
* @magentoAppIsolation enabled
1599+
*/
1600+
public function testImportWithNonExistingImage()
1601+
{
1602+
$products = [
1603+
'simple_new' => 100,
1604+
];
1605+
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
1606+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
1607+
$source = $this->objectManager->create(
1608+
\Magento\ImportExport\Model\Import\Source\Csv::class,
1609+
[
1610+
'file' => __DIR__ . '/_files/products_to_import_with_non_existing_image.csv',
1611+
'directory' => $directory
1612+
]
1613+
);
1614+
1615+
$errors = $this->_model->setParameters(
1616+
['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product']
1617+
)
1618+
->setSource($source)
1619+
->validateData();
1620+
1621+
$this->assertTrue($errors->getErrorsCount() == 0);
1622+
$this->_model->importData();
1623+
1624+
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
1625+
foreach ($products as $productSku => $productQty) {
1626+
$product = $productRepository->get($productSku);
1627+
$stockItem = $product->getExtensionAttributes()->getStockItem();
1628+
$this->assertEquals($productQty, $stockItem->getQty());
1629+
}
1630+
}
1631+
15931632
/**
15941633
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
15951634
* @magentoDbIsolation disabled
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label1,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,crosssell_skus,upsell_skus,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,associated_skus
2+
simple_new,,Default,simple,,base,New Product,,,,1,Taxable Goods,"Catalog, Search",10,,,,new-product,New Product,New Product,New Product ,/no/exists/image/magento_image.jpg,Image Label,magento_small_image.jpg,Small Image Label,magento_thumbnail.jpg,Thumbnail Label,magento_image.jpg,Image Label,10/20/15 07:05,10/20/15 07:05,,,Block after Info Column,,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100,0,1,0,0,1,1,1,10000,1,1,1,1,1,0,1,1,0,0,0,1,,,,"magento_additional_image_one.jpg, magento_additional_image_two.jpg","Additional Image Label One,Additional Image Label Two",,,,,,,,

0 commit comments

Comments
 (0)