Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

[256] Fixed variant collection #331

Conversation

VitaliyBoyko
Copy link
Contributor

Description (*)

This PR fixed empty response for variant in ConfigurableProduct with sample data.

Fixed Issues (if relevant)

  1. [BugFix] Configurable products > Variants > Attributes are empty #256: Configurable products > Variants > Attributes are empty

Manual testing scenarios (*)

Request

{
  products(filter: {sku: {eq: "WP13"}}) {
    items {
      name
      ... on ConfigurableProduct {
        sku
        variants {
          product {
            sku
          }
          attributes {
            label
            code
            value_index
          }
        }
      }
    }
  }
}

Response

{
  "data": {
    "products": {
      "items": [
        {
          "name": "Portia Capri",
          "sku": "WP13",
          "variants": [
            {
              "product": {
                "sku": "WP13-28-Blue"
              },
              "attributes": [
                {
                  "label": "Blue",
                  "code": "color",
                  "value_index": 50
                },
                {
                  "label": "28",
                  "code": "size",
                  "value_index": 172
                }
              ]
            },
            {
              "product": {
                "sku": "WP13-28-Green"
              },
              "attributes": [
                {
                  "label": "Green",
                  "code": "color",
                  "value_index": 53
                },
                {
                  "label": "28",
                  "code": "size",
                  "value_index": 172
                }
              ]
            },
            {
              "product": {
                "sku": "WP13-28-Orange"
              },
              "attributes": [
                {
                  "label": "Orange",
                  "code": "color",
                  "value_index": 56
                },
                {
                  "label": "28",
                  "code": "size",
                  "value_index": 172
                }
              ]
            },
            {
              "product": {
                "sku": "WP13-29-Blue"
              },
              "attributes": [
                {
                  "label": "Blue",
                  "code": "color",
                  "value_index": 50
                },
                {
                  "label": "29",
                  "code": "size",
                  "value_index": 173
                }
              ]
            },
            {
              "product": {
                "sku": "WP13-29-Green"
              },
              "attributes": [
                {
                  "label": "Green",
                  "code": "color",
                  "value_index": 53
                },
                {
                  "label": "29",
                  "code": "size",
                  "value_index": 173
                }
              ]
            },
            {
              "product": {
                "sku": "WP13-29-Orange"
              },
              "attributes": [
                {
                  "label": "Orange",
                  "code": "color",
                  "value_index": 56
                },
                {
                  "label": "29",
                  "code": "size",
                  "value_index": 173
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@naydav
Copy link
Contributor

naydav commented Jan 29, 2019

@VitaliyBoyko Looks like we need to cover functionality with API-functional test
Thanks

@VitaliyBoyko
Copy link
Contributor Author

@VitaliyBoyko Looks like we need to cover functionality with API-functional test
Thanks

I've added an additional check if attributes array contains an item.

@naydav
Copy link
Contributor

naydav commented Feb 6, 2019

@VitaliyBoyko
Pls check

Magento.GraphQl.Catalog.CategoryProductsVariantsTest.testGetSimpleProductsFromCategory
Magento.GraphQl.Catalog.CategoryProductsVariantsTest.testGetSimpleProductsFromCategory
-
Failed asserting that actual size 0 matches expected size 2.
-

Magento.GraphQl.ConfigurableProduct.ConfigurableProductViewTest.testQueryConfigurableProductLinks
Magento.GraphQl.ConfigurableProduct.ConfigurableProductViewTest.testQueryConfigurableProductLinks
-
Precondition failed: 'variants' must not be empty
Failed asserting that an array is not empty.
-

these tests are faliled on Jenkins
Thanks

@@ -35,12 +45,12 @@ public function resolve(
$data = [];
foreach ($value['options'] as $option) {
$code = $option['attribute_code'];
if (!isset($value['product'][$code])) {
if (!isset($value['product']['model'][$code])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we have a problem at this place because $value['product']['model'] contains Product model object

naydav added a commit that referenced this pull request Feb 11, 2019
@magento-engcom-team magento-engcom-team merged commit 2a84778 into 2.3-develop Feb 12, 2019
@ghost
Copy link

ghost commented Feb 12, 2019

Hi @VitaliyBoyko, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants