Skip to content

Commit f96d993

Browse files
committed
#25540: Products are not displaying infront end after updating product via importing CSV.
1 parent 148d6cc commit f96d993

File tree

1 file changed

+28
-20
lines changed
  • app/code/Magento/BundleImportExport/Model/Import/Product/Type

1 file changed

+28
-20
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
* Copyright © Magento, Inc. All rights reserved.
77
* See COPYING.txt for license details.
88
*/
9+
910
namespace Magento\BundleImportExport\Model\Import\Product\Type;
1011

11-
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
12-
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
13-
use Magento\Framework\App\ObjectManager;
1412
use Magento\Bundle\Model\Product\Price as BundlePrice;
1513
use Magento\Catalog\Model\Product\Type\AbstractType;
14+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
1615
use Magento\CatalogImportExport\Model\Import\Product;
16+
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
17+
use Magento\Framework\App\ObjectManager;
1718
use Magento\Framework\App\ResourceConnection;
1819
use Magento\Framework\EntityManager\MetadataPool;
1920
use Magento\Store\Model\StoreManagerInterface;
@@ -26,6 +27,9 @@
2627
*/
2728
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
2829
{
30+
/**
31+
* phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting
32+
*/
2933

3034
/**
3135
* Delimiter before product option value.
@@ -62,6 +66,10 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
6266
*/
6367
const SELECTION_PRICE_TYPE_PERCENT = 1;
6468

69+
/**
70+
* phpcs:enable Magento2.Commenting.ConstantsPHPDocFormatting
71+
*/
72+
6573
/**
6674
* Array of cached options.
6775
*
@@ -133,7 +141,7 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
133141
protected $_optionTypeMapping = [
134142
'dropdown' => 'select',
135143
'radiobutton' => 'radio',
136-
'checkbox' => 'checkbox',
144+
'checkbox' => 'checkbox',
137145
'multiselect' => 'multi',
138146
];
139147

@@ -543,7 +551,7 @@ protected function populateExistingSelections($existingOptions)
543551
? $this->_bundleFieldMapping[$origKey]
544552
: $origKey;
545553
if (
546-
!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
554+
!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
547555
) {
548556
$this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key] =
549557
$existingSelection[$origKey];
@@ -616,6 +624,7 @@ protected function populateInsertOptionValues(array $optionIds): array
616624
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
617625
&& $assoc['parent_id'] == $entityId) {
618626
$option['parent_id'] = $entityId;
627+
//phpcs:ignore Magento2.Performance.ForeachArrayMerge
619628
$optionValues = array_merge(
620629
$optionValues,
621630
$this->populateOptionValueTemplate($option, $optionId)
@@ -675,10 +684,7 @@ private function insertParentChildRelations()
675684
$childIds = [];
676685
foreach ($options as $option) {
677686
foreach ($option['selections'] as $selection) {
678-
if (!isset($selection['parent_product_id'])) {
679-
if (!isset($this->_cachedSkuToProducts[$selection['sku']])) {
680-
continue;
681-
}
687+
if (isset($this->_cachedSkuToProducts[$selection['sku']])) {
682688
$childIds[] = $this->_cachedSkuToProducts[$selection['sku']];
683689
}
684690
}
@@ -735,17 +741,19 @@ protected function deleteOptionsAndSelections($productIds)
735741
$optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
736742
$optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
737743
$selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
738-
$valuesIds = $this->connection->fetchAssoc($this->connection->select()->from(
739-
['bov' => $optionValueTable],
740-
['value_id']
741-
)->joinLeft(
742-
['bo' => $optionTable],
743-
'bo.option_id = bov.option_id',
744-
['option_id']
745-
)->where(
746-
'parent_id IN (?)',
747-
$productIds
748-
));
744+
$valuesIds = $this->connection->fetchAssoc(
745+
$this->connection->select()->from(
746+
['bov' => $optionValueTable],
747+
['value_id']
748+
)->joinLeft(
749+
['bo' => $optionTable],
750+
'bo.option_id = bov.option_id',
751+
['option_id']
752+
)->where(
753+
'parent_id IN (?)',
754+
$productIds
755+
)
756+
);
749757
$this->connection->delete(
750758
$optionValueTable,
751759
$this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))

0 commit comments

Comments
 (0)