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

Conversation

VoronoyAlexandr
Copy link
Contributor

@VoronoyAlexandr VoronoyAlexandr commented Nov 24, 2018

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)

@VoronoyAlexandr VoronoyAlexandr changed the title Fixed variant collection [256] Fixed variant collection Nov 24, 2018
{
if (!in_array($id, $this->parentIds) && !empty($this->childrenMap)) {
if (!in_array($product, $this->parentProduct) && !empty($this->childrenMap)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should not use objects for in_array but you can use structure like key is product id, value is object

* @param \Magento\Catalog\Model\Product $currentProduct
* @return array
*/
private function getAttributesCode(Product $currentProduct): array
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 can use more simple way for loading all of the possible (visible) attribute codes instead of loading attributes models

@naydav
Copy link
Contributor

naydav commented Jan 23, 2019

Hello @VoronoyAlexandr,
We still need some changes to finish the PR, will you continue progress?
Thank you

Please let me know if you need any assistance.

@VitaliyBoyko
Copy link
Contributor

No progress here.
Closing this one.

@ghost
Copy link

ghost commented Jan 29, 2019

Hi @VoronoyAlexandr, 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