magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

CSV Product Import with NO stock changes assigns Products to default source #39354

Closed lbajsarowicz closed 1 week ago

lbajsarowicz commented 2 weeks ago

Preconditions and environment

CSV file:

sku,custom_attribute
AD-1,attribute_value_first
AD-2,attribute_value_second

Steps to reproduce

Provided

  1. I am logged as an Administrator with permission to update Prodcts and Inventories
  2. There are two inventory sources: Default and Online Inventory
  3. The products listed in CSV file exist and are assigned to Online Inventory

Steps

  1. Navigate to System > Data Transfer > Import
  2. Set Entity Type to Products, Import Behavior to Add / Update, select CSV file to import. (see Preconditions)
  3. Perform Import

Expected result

The Products Inventory Source assignment should not change (should still be assigned to Online Inventory only.

Actual result

The Products get assigned to the Default Inventory Source.

Additional information

The problem lies in \Magento\CatalogImportExport\Model\Import\Product::_saveStockItem, which - regardless the Import CSV contains any Inventory changes or not - updates the Inventory.

However, instead of getting the current Inventory settings, it calls \Magento\CatalogImportExport\Model\Import\Product::getRowExistingStockItem, which - under the hood - creates a new inventory entry 🤯 with default Website ID and its Stock:

https://github.com/magento/magento2/blob/0b488dd1139e413cd5711241ae767030081805f6/app/code/Magento/CatalogImportExport/Model/Import/Product.php#L3435-L3440

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 weeks ago

Hi @lbajsarowicz. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.

m2-assistant[bot] commented 2 weeks ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

m2-assistant[bot] commented 2 weeks ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Delta commented 2 weeks ago

Hi @lbajsarowicz,

Thanks for your reporting and collaboration. We have verified the issue in Latest 2.4-develop instance & 2.4.8-beta1 instance, but we are unable to reproduce the issue. Kindly refer the screenshots.

Steps to reproduce

  1. Create two sources Default and Online Inventory
  2. Create AD-1 and AD-2 Product and assign them to online inventory source
  3. Import the csv prod.csv
  4. After import navigate to catalog>products>AD-1 and AD-2 Products
  5. Observe both products are assigned to online inventory and not assigned to default source. image image

Can you please re-verify and confirm if you are still facing the issue. Thanks.

lbajsarowicz commented 1 week ago

@magento give me 2.4-develop instance

lbajsarowicz commented 1 week ago

The problem no longer occurs in the latest (2.4.7) version of Magento. I'll find out what exact Commit fixed the issue and let you know in the thread.