From f96d993184b3aea5512a2c4976f459e712cc14f4 Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Wed, 20 Nov 2019 12:20:33 +0200
Subject: [PATCH 1/4] magento/magento2#25540: Products are not displaying
infront end after updating product via importing CSV.
---
.../Model/Import/Product/Type/Bundle.php | 48 +++++++++++--------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
index 81a47d72602b7..33a7d2efaa273 100644
--- a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
+++ b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
@@ -6,14 +6,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\BundleImportExport\Model\Import\Product\Type;
-use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
-use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
-use Magento\Framework\App\ObjectManager;
use Magento\Bundle\Model\Product\Price as BundlePrice;
use Magento\Catalog\Model\Product\Type\AbstractType;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
use Magento\CatalogImportExport\Model\Import\Product;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Store\Model\StoreManagerInterface;
@@ -26,6 +27,9 @@
*/
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
{
+ /**
+ * phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting
+ */
/**
* Delimiter before product option value.
@@ -62,6 +66,10 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
*/
const SELECTION_PRICE_TYPE_PERCENT = 1;
+ /**
+ * phpcs:enable Magento2.Commenting.ConstantsPHPDocFormatting
+ */
+
/**
* Array of cached options.
*
@@ -133,7 +141,7 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
protected $_optionTypeMapping = [
'dropdown' => 'select',
'radiobutton' => 'radio',
- 'checkbox' => 'checkbox',
+ 'checkbox' => 'checkbox',
'multiselect' => 'multi',
];
@@ -543,7 +551,7 @@ protected function populateExistingSelections($existingOptions)
? $this->_bundleFieldMapping[$origKey]
: $origKey;
if (
- !isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
+ !isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
) {
$this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key] =
$existingSelection[$origKey];
@@ -616,6 +624,7 @@ protected function populateInsertOptionValues(array $optionIds): array
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
&& $assoc['parent_id'] == $entityId) {
$option['parent_id'] = $entityId;
+ //phpcs:ignore Magento2.Performance.ForeachArrayMerge
$optionValues = array_merge(
$optionValues,
$this->populateOptionValueTemplate($option, $optionId)
@@ -675,10 +684,7 @@ private function insertParentChildRelations()
$childIds = [];
foreach ($options as $option) {
foreach ($option['selections'] as $selection) {
- if (!isset($selection['parent_product_id'])) {
- if (!isset($this->_cachedSkuToProducts[$selection['sku']])) {
- continue;
- }
+ if (isset($this->_cachedSkuToProducts[$selection['sku']])) {
$childIds[] = $this->_cachedSkuToProducts[$selection['sku']];
}
}
@@ -735,17 +741,19 @@ protected function deleteOptionsAndSelections($productIds)
$optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
$optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
$selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
- $valuesIds = $this->connection->fetchAssoc($this->connection->select()->from(
- ['bov' => $optionValueTable],
- ['value_id']
- )->joinLeft(
- ['bo' => $optionTable],
- 'bo.option_id = bov.option_id',
- ['option_id']
- )->where(
- 'parent_id IN (?)',
- $productIds
- ));
+ $valuesIds = $this->connection->fetchAssoc(
+ $this->connection->select()->from(
+ ['bov' => $optionValueTable],
+ ['value_id']
+ )->joinLeft(
+ ['bo' => $optionTable],
+ 'bo.option_id = bov.option_id',
+ ['option_id']
+ )->where(
+ 'parent_id IN (?)',
+ $productIds
+ )
+ );
$this->connection->delete(
$optionValueTable,
$this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))
From 6ad372ae3768d10a77810bce9bf2eeb8a5ea01d2 Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Wed, 18 Mar 2020 13:40:49 +0200
Subject: [PATCH 2/4] magento/magento2#25540: Static tests fix.
---
.../BundleImportExport/Model/Import/Product/Type/Bundle.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
index 33a7d2efaa273..dcc6e52460793 100644
--- a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
+++ b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
@@ -20,9 +20,8 @@
use Magento\Store\Model\StoreManagerInterface;
/**
- * Class Bundle
+ * Import entity Bundle product type.
*
- * @package Magento\BundleImportExport\Model\Import\Product\Type
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
@@ -723,6 +722,8 @@ protected function _initAttributes()
}
}
}
+
+ return $this;
}
/**
From a070cf368ed4b19c5e63b4453d9af2d72451901e Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Wed, 18 Mar 2020 15:00:43 +0200
Subject: [PATCH 3/4] magento/magento2#25540: MFTF test added.
---
.../Test/UpdateBundleProductViaImportTest.xml | 70 +++++++++++++++++++
.../_data/catalog_product_import_bundle.csv | 3 +
2 files changed, 73 insertions(+)
create mode 100644 app/code/Magento/BundleImportExport/Test/Mftf/Test/UpdateBundleProductViaImportTest.xml
create mode 100644 dev/tests/acceptance/tests/_data/catalog_product_import_bundle.csv
diff --git a/app/code/Magento/BundleImportExport/Test/Mftf/Test/UpdateBundleProductViaImportTest.xml b/app/code/Magento/BundleImportExport/Test/Mftf/Test/UpdateBundleProductViaImportTest.xml
new file mode 100644
index 0000000000000..45b4c4f5ededd
--- /dev/null
+++ b/app/code/Magento/BundleImportExport/Test/Mftf/Test/UpdateBundleProductViaImportTest.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/_data/catalog_product_import_bundle.csv b/dev/tests/acceptance/tests/_data/catalog_product_import_bundle.csv
new file mode 100644
index 0000000000000..6804675940a02
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/catalog_product_import_bundle.csv
@@ -0,0 +1,3 @@
+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_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,related_position,crosssell_skus,crosssell_position,upsell_skus,upsell_position,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,bundle_shipment_type,associated_skus,downloadable_links,downloadable_samples,configurable_variations,configurable_variation_labels
+Simple,,Default,simple,"Default Category/New",base,Simple,,,1.000000,1,"Taxable Goods","Catalog, Search",100.000000,,,,simple,Simple,Simple,"Simple ",,,,,,,,,"3/18/20, 6:56 AM","3/18/20, 6:56 AM",,,"Block after Info Column",,,,"Use config",,,,,,,"Use config",,,1000.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
+Bundle,,Default,bundle,"Default Category/New",base,Bundle,,,,1,"Taxable Goods","Catalog, Search",,,,,bundle,Bundle,Bundle,"Bundle ",,,,,,,,,"3/18/20, 6:57 AM","3/18/20, 6:57 AM",,,"Block after Info Column",,,,"Use config",,,,,,,"Use config",,,0.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,dynamic,dynamic,"Price range",dynamic,"name=Test Option,type=select,required=1,sku=Simple,price=0.0000,default=1,default_qty=1.0000,price_type=fixed,can_change_qty=0",together,,,,,
From 143bd5b5bce5284d53a5e13f6a3b0863f6a2c66b Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Thu, 19 Mar 2020 14:58:10 +0200
Subject: [PATCH 4/4] magento/magento2#25540: Refactoring.
---
.../Model/Import/Product/Type/Bundle.php | 20 -------------------
1 file changed, 20 deletions(-)
diff --git a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
index dcc6e52460793..e6522054d9f94 100644
--- a/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
+++ b/app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php
@@ -26,18 +26,11 @@
*/
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
{
- /**
- * phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting
- */
-
/**
* Delimiter before product option value.
*/
const BEFORE_OPTION_VALUE_DELIMITER = ';';
- /**
- * Pair value separator.
- */
const PAIR_VALUE_SEPARATOR = '=';
/**
@@ -50,25 +43,12 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
*/
const VALUE_FIXED = 'fixed';
- /**
- * Not fixed dynamic attribute.
- */
const NOT_FIXED_DYNAMIC_ATTRIBUTE = 'price_view';
- /**
- * Selection price type fixed.
- */
const SELECTION_PRICE_TYPE_FIXED = 0;
- /**
- * Selection price type percent.
- */
const SELECTION_PRICE_TYPE_PERCENT = 1;
- /**
- * phpcs:enable Magento2.Commenting.ConstantsPHPDocFormatting
- */
-
/**
* Array of cached options.
*