Last active
June 23, 2023 04:55
-
-
Save FactoryAidan/a8d5db00eb0bc4cac792adf2364ff698 to your computer and use it in GitHub Desktop.
Magento 2.4.0 update of `vendor/magento/module-catalog-import-export/Model/Import/Product.php::_prepareRowForDb()` to handle both `array|null` return types from `$this->skuProcessor->getNewSku()`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/vendor/magento/module-catalog-import-export/Model/Import/Product.php b/vendor/magento/module-catalog-import-export/Model/Import/Product.php | |
index 25bbecdce..1c50196a2 100644 | |
--- a/vendor/magento/module-catalog-import-export/Model/Import/Product.php | |
+++ b/vendor/magento/module-catalog-import-export/Model/Import/Product.php | |
@@ -1278,8 +1278,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity | |
if ($this->isSkuExist($lastSku)) { | |
$newSku = $this->skuProcessor->getNewSku($lastSku); | |
- $rowData[self::COL_ATTR_SET] = $newSku['attr_set_code']; | |
- $rowData[self::COL_TYPE] = $newSku['type_id']; | |
+ // 👆 can return array|null but null is not handled. | |
+ if( is_array($newSku) ){ | |
+ $rowData[self::COL_ATTR_SET] = $newSku['attr_set_code']; | |
+ $rowData[self::COL_TYPE] = $newSku['type_id']; | |
+ } | |
} | |
return $rowData; |
Alternate Solution (also I've added this to my question on magento.stackexchange.com, thanks again for your response):
app/code/VendorName/ModuleName/etc/di.xml
:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Firebear\ImportExport\Model\Import\Product" type="VendorName\ModuleName\Model\Import\Product"/>
</config>
app/code/VendorName/ModuleName/Model/Import/Product.php
:
<?php
declare(strict_types=1);
namespace VendorName\ModuleName\Model\Import;
class Product extends \Firebear\ImportExport\Model\Import\Product
{
protected function _prepareRowForDb(array $rowData): array
{
$level = error_reporting();
if (E_NOTICE & $level === 0) {
return parent::_prepareRowForDb($rowData);
}
error_reporting($level & ~E_NOTICE);
$rowData = parent::_prepareRowForDb($rowData);
error_reporting($level);
return $rowData;
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{your_web_root}/m2-hotfixes/*
{your_web_root}/composer.json
:composer update;
to reinstall themagento/module-catalog-import-export
module with the patch applied.