magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

GQL product query doesn't response for product that is set visibility as "Search" #36857

Closed adarshkhatri closed 1 year ago

adarshkhatri commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Create a product and set it's visibility to search
  2. Query for GQL
query products(
    $filter: ProductAttributeFilterInput
    ) {
      products(
          filter: $filter
    ) {
        total_count
      items {
          type_id
          sku
          url_key
   }
}

Variable:

{
  "filter": {
      "sku": {
          "eq": "your-product-sku"
        }
  }
}

Expected result

The response should have a product.

Actual result

The response is empty.

Additional information

It looks Magento adds visibility as 2 and 4 by default while doing GQL query. It make sense when doing query for the category page. But how about the product detail page?

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @adarshkhatri. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

adarshkhatri commented 1 year ago

@magento give me 2.4-develop instance - upcoming 2.4.x release

magento-deployment-service[bot] commented 1 year ago

Hi @adarshkhatri. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @adarshkhatri, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_5a7f Login: 252163c5 Password: 329f56b8a069

adarshkhatri commented 1 year ago

I was able to reproduce in above instance.

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_86e5 Login: b50c8847 Password: e81d88c79989

engcom-Bravo commented 1 year ago

Hi @adarshkhatri,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

1.Create a product and set it's visibility to search 2.Query for GQL

Screenshot 2023-02-14 at 2 51 08 PM

As per magento devdocs when we set to product visibility to search it will be found through search tool.

Screenshot 2023-02-14 at 2 52 28 PM

Kindly go through with this document https://docs.magento.com/user-guide/v2.3/sales-channels/amazon/creating-assigning-catalog-products.html#create-a-multiple-catalog-products-using-their-amazon-listing-information and please let us know if you are still facing any issue.

Thanks.

adarshkhatri commented 1 year ago

Isn't that the issue I reported that is response has no product?

adarshkhatri commented 1 year ago

If this is expected, then what is the query should I run to take customer to product detail page?

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_3898 Login: 732b15f7 Password: 541eea619e2d

engcom-Bravo commented 1 year ago

Hi @adarshkhatri,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

1.Create a product and set it's visibility to search

Simpless-Products-Inventory-Catalog-Magento-Admin

We have used below query for a product when set visibility as "search".We got a response for a product.

{
  products(search: "Product SKU") {
    items {
      name
      sku
      url_rewrites {
        url
        parameters {
          name
          value
        }
      }
    }
  }
}
Screenshot 2023-02-16 at 2 55 47 PM

Kindly let us know if we are still facing any issue.

Thanks.

adarshkhatri commented 1 year ago

Above query would be for your search result page. now how will you take your customer to product detail page? You cannot rely on ‘search query’ to take your customer to PDP.

The way we do it, we remove the “search” query and pass the SKU as a filter when taking to PDP.

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_40a5 Login: e493355e Password: 56c72a1d1c64

engcom-Bravo commented 1 year ago

Hi @adarshkhatri,

Thanks for your update.

As per Magento devdocs when we set visibility to searchthe product should be only searchable,and also we cannot find that product in categories kindly refer the attached video.

https://user-images.githubusercontent.com/51680745/220626105-a3485213-e9bb-488d-83f4-7d032b3b9bd0.mov

ProductA-Products-Inventory-Catalog-Magento-Admin

We have used below graphql query for a product when we set visibility to search.we got the response.

{
  products(
    search: "ProductA"

  ) {
    items {
      name
      sku
      price_range {
        minimum_price {
          regular_price {
            value
            currency
          }
        }
      }
    }
    total_count
    page_info {
      page_size
    }
  }
}
Screenshot 2023-02-22 at 2 34 28 PM

Since the product is not showing an category page we cannot filter the product.Kindly let us know if you are still facing any issue.Please let us know if we missed anything.

Thanks.

adarshkhatri commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @adarshkhatri. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @adarshkhatri, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_3525 Login: 259c2238 Password: 26f6e359402e

adarshkhatri commented 1 year ago

Ok, I think we are going in circle. I agree with you on search result page. But I am trying to understand your approach for PDP.

Below is the approach I am using for my storefront.

Have a look this URL: https://venia.magento.com/graphql?query=query+getProductDetailForProductPage%28%24urlKey%3AString%21%29%7Bproducts%28filter%3A%7Burl_key%3A%7Beq%3A%24urlKey%7D%7D%29%7Bitems%7Bid+uid+...ProductDetailsFragment+__typename%7D__typename%7D%7Dfragment+ProductDetailsFragment+on+ProductInterface%7B__typename+categories%7Buid+breadcrumbs%7Bcategory_uid+__typename%7D__typename%7Ddescription%7Bhtml+__typename%7Dshort_description%7Bhtml+__typename%7Did+uid+media_gallery_entries%7Buid+label+position+disabled+file+__typename%7Dmeta_description+name+price%7BregularPrice%7Bamount%7Bcurrency+value+__typename%7D__typename%7D__typename%7Dprice_range%7Bmaximum_price%7Bfinal_price%7Bcurrency+value+__typename%7Ddiscount%7Bamount_off+__typename%7D__typename%7D__typename%7Dsku+small_image%7Burl+__typename%7Dstock_status+url_key+custom_attributes%7Bselected_attribute_options%7Battribute_option%7Buid+label+is_default+__typename%7D__typename%7Dentered_attribute_value%7Bvalue+__typename%7Dattribute_metadata%7Buid+code+label+attribute_labels%7Bstore_code+label+__typename%7Ddata_type+is_system+entity_type+ui_input%7Bui_input_type+is_html_allowed+__typename%7D...on+ProductAttributeMetadata%7Bused_in_components+__typename%7D__typename%7D__typename%7D...on+ConfigurableProduct%7Bconfigurable_options%7Battribute_code+attribute_id+uid+label+values%7Buid+default_label+label+store_label+use_default_value+value_index+swatch_data%7B...on+ImageSwatchData%7Bthumbnail+__typename%7Dvalue+__typename%7D__typename%7D__typename%7Dvariants%7Battributes%7Bcode+value_index+__typename%7Dproduct%7Buid+media_gallery_entries%7Buid+disabled+file+label+position+__typename%7Dsku+stock_status+price%7BregularPrice%7Bamount%7Bcurrency+value+__typename%7D__typename%7D__typename%7Dprice_range%7Bmaximum_price%7Bfinal_price%7Bcurrency+value+__typename%7Ddiscount%7Bamount_off+__typename%7D__typename%7D__typename%7Dcustom_attributes%7Bselected_attribute_options%7Battribute_option%7Buid+label+is_default+__typename%7D__typename%7Dentered_attribute_value%7Bvalue+__typename%7Dattribute_metadata%7Buid+code+label+attribute_labels%7Bstore_code+label+__typename%7Ddata_type+is_system+entity_type+ui_input%7Bui_input_type+is_html_allowed+__typename%7D...on+ProductAttributeMetadata%7Bused_in_components+__typename%7D__typename%7D__typename%7D__typename%7D__typename%7D__typename%7D%7D&operationName=getProductDetailForProductPage&variables=%7B%22urlKey%22%3A%22penelope-peasant-blouse%22%7D

And https://venia.magento.com/penelope-peasant-blouse.html As you see, for the PDP there the query: getProductDetailForProductPage($urlKey:String!)

and fitler by url_key: {"urlKey":"penelope-peasant-blouse"} in the filter payload.

With this fitler, the response is null.

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_eba0 Login: 7cc73077 Password: 4fa3868fb7f3

engcom-Bravo commented 1 year ago

Hi @adarshkhatri,

Thanks for your update.

We have created 3 products with visilibity to search.These products we cannot found in category.we tried using search tool.

Screenshot 2023-02-23 at 4 33 05 PM

We have used below query with filter input.We got response.

{
  products(
    search: "ProductA"
    filter: { sku: { eq: "ProductAAA" } }
  ) {
    items {
      name
      sku

      price_range {
        minimum_price {
          regular_price {
            value
            currency
          }
        }
      }
    }
    total_count
    page_info {
      page_size
    }
  }
}
Screenshot 2023-02-23 at 5 09 55 PM

We are able to filter the product with SKU.

Kindly let us know if we missed anything.

Thanks.

adarshkhatri commented 1 year ago

You are using search for the product query in PDP. As we know search query may not give you the exact product. The search query is for catalog search.

As you can see your own demo PWA link https://venia.magento.com/penelope-peasant-blouse.html it is not using search query

query getProductDetailForProductPage($urlKey:String!){
  products(
    filter:{
      url_key:{eq:$urlKey}
    }
  ){
    items{
      id
      uid 
      ...ProductDetailsFragment 
        __typename
    }
    __typename
  }
}

Can you confirm or point me to a Magento doc about the PDP page query approach to use search in a query?

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering Admin access: https://a8e18a502c712ea06a567934a0b8b1a6.instances.magento-community.engineering/admin_8410 Login: 07c77e17 Password: 1e07e824c85d

engcom-Bravo commented 1 year ago

Hi @adarshkhatri,

Thanks for your update.

We have tried below query using search.we got response for PDP page.

query {
  productDetail: products(
  search: "ProductA"
    filter: { sku: { eq: "ProductAAA" } }
  ) {
    total_count
    items {
      sku
      id
      name
      __typename
      price_range {
        minimum_price {
          regular_price {
            value
            currency
          }
        }
      }
      }

      }

          }
Screenshot 2023-02-24 at 3 02 07 PM

As per Magento devdocs https://developer.adobe.com/commerce/webapi/graphql/schema/products/queries/products/#deprecated-output-attributes. filter withurl_key is deprecated.

products-query-Commerce-Web-APIs

For url_key we have to use route query.Please check this document https://developer.adobe.com/commerce/webapi/graphql/schema/products/queries/route/.

Screenshot 2023-02-24 at 3 08 38 PM

Kindly let us know if you are still facing any issue.

Thanks.

adarshkhatri commented 1 year ago

I think we are going in circles. Please close the ticket if you think there is no problem. I have already patched our version.

engcom-Bravo commented 1 year ago

Hi @adarshkhatri,

Thanks for your update.

As per latest comment https://github.com/magento/magento2/issues/36857#issuecomment-1445012602 we are closing this issue. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.

oleksiyzestlogic commented 1 year ago

I have the same issue as @adarshkhatri. I think we should reopen task.

Maybe it's an issue from the PWA side and we should use another query, but for now it's products with filter still:

image

Query is:

query getProductDetailForProductPage($urlKey:String!) {
    products(filter:{url_key:{eq:$urlKey}}) {
        items {
            ...
        }
    }
}

And this query has build in filter by visibility and products with visibility "Search" ignored.

BITS-Martin commented 2 months ago

I think we are going in circles. Please close the ticket if you think there is no problem. I have already patched our version.

@adarshkhatri how did you resolve the issue? We encounter the same problem in 2.4.5-p8 aswell.