Skip to content

Commit e9e83fa

Browse files
author
Victor Rad
committed
Merge remote-tracking branch 'origin/MAGETWO-45086' into develop
2 parents db68831 + 422a5be commit e9e83fa

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
283283
'small_image_label',
284284
'thumbnail_image',
285285
'thumbnail_image_label',
286+
'swatch_image',
287+
'swatch_image_label',
286288
'created_at',
287289
'updated_at',
288290
'new_from_date',

app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Simple.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ class Simple extends \Magento\CatalogImportExport\Model\Export\Product\Type\Abst
3333
'old_id',
3434
'tier_price',
3535
'category_ids',
36+
'has_options',
37+
'is_returnable',
38+
'required_options',
39+
'quantity_and_stock_status'
3640
];
3741
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
363363
*
364364
* @var string[]
365365
*/
366-
protected $_imagesArrayKeys = ['_media_image', 'image', 'small_image', 'thumbnail'];
366+
protected $_imagesArrayKeys = ['_media_image', 'image', 'small_image', 'thumbnail', 'swatch_image'];
367367

368368
/**
369369
* Permanent entity columns.
@@ -2110,7 +2110,13 @@ public function validateRow(array $rowData, $rowNum)
21102110

21112111
$rowScope = $this->getRowScope($rowData);
21122112

2113-
// BEHAVIOR_DELETE use specific validation logic
2113+
// BEHAVIOR_DELETE and BEHAVIOR_REPLACE use specific validation logic
2114+
if (Import::BEHAVIOR_REPLACE == $this->getBehavior()) {
2115+
if (self::SCOPE_DEFAULT == $rowScope && !isset($this->_oldSku[$rowData[self::COL_SKU]])) {
2116+
$this->addRowError(ValidatorInterface::ERROR_SKU_NOT_FOUND_FOR_DELETE, $rowNum);
2117+
return false;
2118+
}
2119+
}
21142120
if (Import::BEHAVIOR_DELETE == $this->getBehavior()) {
21152121
if (self::SCOPE_DEFAULT == $rowScope && !isset($this->_oldSku[$rowData[self::COL_SKU]])) {
21162122
$this->addRowError(ValidatorInterface::ERROR_SKU_NOT_FOUND_FOR_DELETE, $rowNum);

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -651,18 +651,18 @@ public function testValidateRowIsAlreadyValidated()
651651
}
652652

653653
/**
654-
* @dataProvider validateRowDeleteBehaviourDataProvider
654+
* @dataProvider validateRowDataProvider
655655
*/
656-
public function testValidateRowDeleteBehaviour($rowScope, $oldSku, $expectedResult)
656+
public function testValidateRow($rowScope, $oldSku, $expectedResult, $behaviour = Import::BEHAVIOR_DELETE)
657657
{
658658
$importProduct = $this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\Product')
659659
->disableOriginalConstructor()
660660
->setMethods(['getBehavior', 'getRowScope', 'getErrorAggregator'])
661661
->getMock();
662662
$importProduct
663-
->expects($this->once())
663+
->expects($this->any())
664664
->method('getBehavior')
665-
->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_DELETE);
665+
->willReturn($behaviour);
666666
$importProduct
667667
->method('getErrorAggregator')
668668
->willReturn($this->getErrorAggregatorObject());
@@ -684,7 +684,7 @@ public function testValidateRowDeleteBehaviourAddRowErrorCall()
684684
->setMethods(['getBehavior', 'getRowScope', 'addRowError'])
685685
->getMock();
686686

687-
$importProduct->expects($this->once())->method('getBehavior')
687+
$importProduct->expects($this->exactly(2))->method('getBehavior')
688688
->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_DELETE);
689689
$importProduct->expects($this->once())->method('getRowScope')
690690
->willReturn(\Magento\CatalogImportExport\Model\Import\Product::SCOPE_DEFAULT);
@@ -1291,7 +1291,7 @@ public function validateRowCheckSpecifiedSkuDataProvider()
12911291
];
12921292
}
12931293

1294-
public function validateRowDeleteBehaviourDataProvider()
1294+
public function validateRowDataProvider()
12951295
{
12961296
return [
12971297
[
@@ -1314,6 +1314,12 @@ public function validateRowDeleteBehaviourDataProvider()
13141314
'$oldSku' => true,
13151315
'$expectedResult' => true,
13161316
],
1317+
[
1318+
'$rowScope' => \Magento\CatalogImportExport\Model\Import\Product::SCOPE_DEFAULT,
1319+
'$oldSku' => null,
1320+
'$expectedResult' => false,
1321+
'$behaviour' => Import::BEHAVIOR_REPLACE
1322+
],
13171323
];
13181324
}
13191325

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ public function testSaveMediaImage()
552552
'Magento\Catalog\Model\Product'
553553
);
554554
$product->load($productId);
555+
$this->assertEquals('/m/a/magento_image.jpg', $product->getData('swatch_image'));
555556
$gallery = $product->getMediaGalleryImages();
556557
$this->assertInstanceOf('Magento\Framework\Data\Collection', $gallery);
557558
$items = $gallery->getItems();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +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,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 ,magento_image.jpg,,magento_image.jpg,,magento_image.jpg,,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_image.jpg,Image Label,,,,,,,,
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 ,magento_image.jpg,,magento_image.jpg,,magento_image.jpg,,magento_image.jpg,,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_image.jpg,Image Label,,,,,,,,

0 commit comments

Comments
 (0)