Skip to content

Refactor import and export #20

@naydav

Description

@naydav

Full context in documentation

[HLD] Inconsistent saving of Stock Data

Description

1. Skip attribute from import

For \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType:

namespace Magento\CatalogImportExport\Model\Import\Product\Type;
abstract class AbstractType
{
    /**
     * This property has been added in scope of work for backward compatible of stock item processing (work with
     * stock_data and quantity_and_stock_status keys)
     * quantity_and_stock_status attribute will be deleted
     *
     * @var array
     */
    private $attributesToSkip = ['quantity_and_stock_status']; // values must be configurable via DI
    ...
    public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDefaultValue = true)
    {
        $resultAttrs = [];
    
        foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
            if ($attrParams['is_static'] || in_array($attrCode, $this->attributesToSkip)) {
                continue;
            }
    ...
}

For the import test, \Magento\CatalogImportExport\Model\AbstractProductExportImportTestCase:

namespace Magento\CatalogImportExport\Model;

abstract class AbstractProductExportImportTestCase extends \PHPUnit_Framework_TestCase
{
    ...
    public static $skippedAttributes = [
    ...
    'quantity_and_stock_status',
    ];
    ...
}    

2. [Important!] Check possibility to disable/enable the Out of Stock status when importing products

3. Check and if needed replace 'quantity_and_stock_status' attribute with stock item data in Import/Export.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions