Skip to content

[357.2] Configurable variants saving to cache  #330

Closed
@RuslanKostiv1

Description

@RuslanKostiv1

Subtask of #357

Description

  • Configurable variants should be exposed via Export API.
  • New feed indexer should be used

Steps

option_valuess is an array of values that have the following format:

parent_id:option_id/optionValue.uid where

parent_id - is configurable product id.

option_id - for configurable product attribute_code is used to determine option_id.

<record name="ProductOption">
    ...
    <field name="id" type="ID" /> <!-- attribute_code of product custom attribute for configurable product
    ...
</record>

optionValue.uid - is uid of product option value (see \Magento\CatalogDataExporter\Model\Provider\Product\ProductOptions\OptionValueUid as example).
Take a look how optionValue.uid is generated into magento (\Magento\ConfigurableProductGraphQl\Model\Resolver\Variant\Attributes\ConfigurableAttributeUid) and use the same approach here.

Need to create factory that generates option_values based on variant type
<!--di.xml -->

<type name="Magento\CatalogDataExporter\Model\Provider\Product\ProductVariants\OptionValueFactory"> <!-- accepts array of option_values generators -->
    <arguments>
        <argument name="variantTypes" xsi:type="array">
            <!-- pay attention that option_values generators must be placed in appropriate module -->
            <item name="configurable" xsi:type="string">Magento\ConfigurableProductDataExporter\Model\Provider\Product\ProductVariants\ConfigurableOptionValue</item>
            <!-- ^^^ create interface and extend ConfigurableOptionValue from it -->
        </argument>
    </arguments>
</type>

The same approach must be used with ProductVariant->id

id (variantId) has the following format

:prefix:/:parentId:/:simpleProductId: where
:prefix: - is a configurable for configurable product
:parentId: - is a configurable product id.
:simpleProductId: - is an id of simple product that represents variation.

Need to create factory that generates id based on variant type
<!--di.xml -->

<type name="Magento\CatalogDataExporter\Model\Provider\Product\ProductVariants\IdFactory"> <!-- accepts array of option_values generators -->
    <arguments>
        <argument name="variantTypes" xsi:type="array">
            <!-- pay attention that id generators must be placed in appropriate module -->
            <item name="configurable" xsi:type="string">Magento\ConfigurableProductDataExporter\Model\Provider\Product\ProductVariants\ConfigurableId</item>
            <!-- ^^^ create interface and extend ConfigurableId from it -->
        </argument>
    </arguments>
</type>
  • cover changes with Web-API tests

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions