Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variants collection returns null in Adobe cloud commerce due to usage of row_id for product mapping. #5194

Open
NavaneethVijay opened this issue Sep 15, 2022 · 0 comments · May be fixed by scandipwa/catalog-graphql#142
Labels

Comments

@NavaneethVijay
Copy link

Steps to reproduce:

  1. Import coonfigurable products in Adobe commerce
  2. Truncate the product entity and reset the auto increment to start from 1
  3. Reimport the products in Adobe commerce

Actual result
Undefied index exception while returning the variants collection at
vendor/scandipwa/catalog-graphql/src/Model/Variant/Collection.php while accessing $childCollectionMap

Expected result
Variants should be returns for the configurable details

Reason for this issue
Adobe commerce uses row_id from product_entity for mapping the child products and its parent product, where as in the Collection class it uses entity_id to access this.

If the products are imported without resetting the auto incrementer, it works fine as the value for entity_id and row_id will be same.

Solution
We can use
Magento\Framework\EntityManager\MetadataPool to fetch the row_id or entity_id depending on the Magento version where ScandiPWA is used.

For example:

 $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
 $productId = $product->getData($linkField);

Instead of using $product->getId();
This way of accessing the products will make sure Scandipwa is compatible with Magento Commerce data.

Versions

  • ScandiPWA: 5.2.7
  • scandipwa/catalog-graphql
@NavaneethVijay NavaneethVijay changed the title Variants collection return null in Adobe cloud commerce due to usage of row_id for product mapping. Variants collection returns null in Adobe cloud commerce due to usage of row_id for product mapping. Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 participant