Description
Subtask of #357
Description
- Configurable variants should be exposed via Export API.
- New feed indexer should be used
Steps
- use branch from PR https://github.com/magento/saas-export/pull/119 as base (reuse it)
- make sure changes from [326.1] Variants update in proto scheme #327 are present into working branch (et_schema updates and autogenerated files)
- see https://github.com/magento/catalog-storefront/blob/develop/dev/docs/designDocuments/Configurable-products-option-variants.md#saas-export-part for data structure
- implement variants export for the configurable product (@see
\Magento\CatalogDataExporter\Model\Provider\ProductVariants
and\Magento\CatalogDataExporter\Model\Provider\ProductVariants\SelectableOptionVariants
)
Product variants include two specific fields:id
andoption_values
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