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

Added URL rewrites data to the product interface #107

Merged
merged 17 commits into from
Oct 4, 2018

Conversation

rogyar
Copy link
Contributor

@rogyar rogyar commented Jun 30, 2018

Description

Added URL rewrites data to the GraphQL product interface. So, now we have a possibility to fetch all URL rewrites for a product with request URL data and target URL parameters.

Also, the old UrlRewrite resolver has been renamed to EntityUrl to make the class name match its purpose.

Fixed Issues (if relevant)

  1. Return URL Rewrites for products #84

Manual testing scenarios

  • Create a product with name "configurable" and assign it to a category
  • Use the following request to fetch the product data:
{
    products (search:"conf") {
        items {
            name,
            sku,
            description,
          	url_rewrites {
              url,
              parameters {
                name,
                value
              }
            }
        }
    }
}
  • You should see 2 URL rewrites in the response like in the following example:
{
  "data": {
    "products": {
      "items": [
        {
          "name": "Configurable",
          "sku": "Configurable",
          "description": null,
          "url_rewrites": [
            {
              "url": "configurable.html",
              "parameters": [
                {
                  "name": "id",
                  "value": "5"
                }
              ]
            },
            {
              "url": "some-category/configurable.html",
              "parameters": [
                {
                  "name": "id",
                  "value": "5"
                },
                {
                  "name": "category",
                  "value": "3"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

@rogyar rogyar removed the requires-tests PRs which require GraphQL tests label Jul 20, 2018
use Magento\UrlRewriteGraphQl\Model\Resolver\UrlRewrite\CustomUrlLocatorInterface;

/**
* UrlRewrite field resolver, used for GraphQL request processing.

Choose a reason for hiding this comment

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

As EntityUrl and UrlRewrite are pretty similar it is better to describe their purpose in class comments (now both classes have same description so to understand what is needed source code should be explored)

@@ -280,6 +280,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
manufacturer: Int @doc(description: "A number representing the product's manufacturer")
categories: [CategoryInterface] @doc(description: "The categories assigned to a product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Categories")
canonical_url: String @doc(description: "Canonical URL") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CanonicalUrl")
url_rewrites: [UrlRewrite] @doc(description: "URL rewrites list") @resolver(class: "Magento\\UrlRewriteGraphQl\\Model\\Resolver\\UrlRewrite")
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 need to move all of this functionality to CatalogUrlRewriteGraphQl

magento-engcom-team pushed a commit that referenced this pull request Sep 14, 2018
) {
$this->urlFinder = $urlFinder;
$this->storeManager = $storeManager;
$this->valueFactory = $valueFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls remove using Factory

# Conflicts:
#	app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php
# Conflicts:
#	app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php
#	app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls
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.

6 participants