Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit fe8777d

Browse files
authored
Merge Q4-integration into develop (#5619)
* update deprecated description * Revert "update deprecated description" This reverts commit c9b39a0. * GraphQL: update description of deprecated directive (#5213) * update deprecated description * review comments * MC-19250: The stuck deployment on the Cloud because of consumers (#5289) * MC-19250: The stuck deployment on the Cloud because of consumers * Update _includes/config/consumers.md Co-Authored-By: Margaret Eker <[email protected]> * GraphQL: Add layered navigation documentation (#5222) * add filtering example * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * linting errors * fix link * update opening sentence * remove bogus commit * Apply suggestions from code review Co-Authored-By: Erik Marr <[email protected]> * change code gates * final review comments * deprecation notices (#5413) * review draft (#5426) * GraphQL: Add fields and example showing cart rule discounts (#5425) * review draft * minor tweaks * review comment * update example * MC-18725: Write article with clarification of how to use this functionality * MC-18725: Write article with clarification of how customer data works * MC-18725: Write article with clarification of how customer data works * Small grammar changes. * GraphQL: Update pricing schema changes (#5512) * checkpoint * checkpoint * minor updates * review comments * one more review comment * more review comments * correct linting error * remove stray character from TOC * Add store name to store config query schema (#5448) * GraphQL: Add categoryList query (#5562) * checkpoint * review draft * fix linting errors * add to list of cached queries * update example to show usage of * clarify match filters * Apply suggestions from code review Added review comments Co-Authored-By: Jeff Matthews <[email protected]> * update sample * rename file * review comment from Dan * developer feedback * resolve more merge conflicts * linting errors * linting errors
1 parent f9abe4f commit fe8777d

File tree

23 files changed

+2648
-110
lines changed

23 files changed

+2648
-110
lines changed

_data/toc/graphql.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pages:
1616
- label: GraphQL Caching
1717
url: /graphql/caching.html
1818

19+
- label: Filtering with custom attributes
20+
url: /graphql/custom-filters.html
21+
1922
- label: Development
2023
children:
2124
- label: Define the GraphQL schema for a module
@@ -50,6 +53,9 @@ pages:
5053
- label: category query
5154
url: /graphql/queries/category.html
5255

56+
- label: categoryList query
57+
url: /graphql/queries/category-list.html
58+
5359
- label: checkoutAgreements query
5460
url: /graphql/queries/checkout-agreements.html
5561

@@ -95,9 +101,12 @@ pages:
95101
- label: isEmailAvailable query
96102
url: /graphql/queries/is-email-available.html
97103

98-
- label: products query
104+
- label: products query (2.3.3)
99105
url: /graphql/queries/products.html
100106

107+
- label: products query (2.3.4)
108+
url: /graphql/queries/products-234.html
109+
101110
- label: storeConfig query
102111
url: /graphql/queries/store-config.html
103112

_includes/config/consumers.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Name|Value|Required?|
2+
|`--consumers-wait-for-messages`|Should consumers wait for a message from the queue? 1 - Yes, 0 - No|No|
3+
{:style="table-layout:auto;"}
4+
5+
`0`—Consumers process available messages in the queue, close the TCP connection, and terminate. Consumers do not wait for additional messages to enter the queue, even if the number of processed messages is less than the `--max_messages` value specified during starting consumers.
6+
7+
`1`—Consumers continue to process messages from the message queue until reaching the maximum number of messages (the value specified for `--max_messages` on the `queue:consumers:start` command) before closing the TCP connection and terminating the consumer process. If the queue empties before reaching `--max_messages` the consumer waits for more messages to arrive. If you use workers to run consumers instead of using a cron job, set this variable to `1`.

_includes/graphql/cart-object.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Attribute | Data Type | Description
22
--- | --- | ---
3-
`applied_coupon` | [`AppliedCoupon`][AppliedCoupon] | The `AppliedCoupon` object contains the `code` text attribute, which specifies the coupon code
3+
`applied_coupon` | [`AppliedCoupon`][AppliedCoupon] | Deprecated. Use `applied_coupons` instead
4+
`applied_coupons` | [[`AppliedCoupon`]][AppliedCoupon] | An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code
45
`applied_gift_cards` | [[`AppliedGiftCard`]][AppliedGiftCard] | An array of `AppliedGiftCard` objects. An `AppliedGiftCard` object contains the `code` text attribute, which specifies the gift card code. `applied_gift_cards` is a Commerce-only attribute, defined in the GiftCardAccountGraphQl module
56
`applied_store_credit` | [`AppliedStoreCredit`][AppliedStoreCredit] | Contains store credit information applied to the cart. `applied_store_credit` is a Commerce-only attribute, defined in the CustomerBalanceGraphQl module
67
`available_payment_methods` | [[AvailablePaymentMethod]][AvailablePaymentMethod] | Available payment methods

guides/v2.2/install-gde/install/cli/install-cli-subcommands-lock.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ Before you run this command, you must do all of the following *or* you must [ins
1818
* [Create or update the deployment configuration]({{ page.baseurl }}/install-gde/install/cli/install-cli-subcommands-deployment.html)
1919
* [Create the Magento database schema]({{ page.baseurl }}/install-gde/install/cli/install-cli-subcommands-db.html)
2020

21-
{% include install/fully-secure.md %}
22-
2321
## Configure the lock {#instgde-cli-lockconfig}
2422

2523
Configure a lock provider to prevent the launch of duplicate cron jobs and cron groups. (Requires Magento 2.2.5 and later 2.2.x versions or version 2.3.2 and later.)
@@ -31,7 +29,7 @@ If you are running Magento Commerce on the cloud infrastructure, you do not need
3129
> Command usage
3230
3331
```bash
34-
magento setup:store-config:set [--<parameter_name>=<value>, ...]
32+
magento setup:config:set [--<parameter_name>=<value>, ...]
3533
```
3634

3735
> Parameter descriptions

guides/v2.3/extension-dev-guide/cache/page-caching/private-content.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
group: php-developer-guide
3+
title: Private content
4+
redirect_from:
5+
- /guides/v2.2/config-guide/cache/cache-priv-priv.html
6+
- /guides/v2.2/config-guide/cache/cache-priv-context.html
7+
- /guides/v2.2/config-guide/cache/cache-priv-inval.html
8+
---
9+
10+
{::options syntax_highlighter="rouge" /}
11+
12+
Since private content is specific to individual users, it is reasonable to handle it on the client side (i.e., web browser).
13+
14+
Use our [customer-data]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Customer/view/frontend/web/js/customer-data.js){:target="_blank"} JS library to store private data in local storage, invalidate private data using customizable rules, and synchronize data with the backend.
15+
16+
This example displays a customer's name on a cacheable page.
17+
18+
## Create a section source {#config-cache-priv-how-source}
19+
20+
The `section source` class is responsible for retrieving data for the section. As a best practice, Magento recommends that you put your code within `Vendor/ModuleName/CustomerData` namespace. Your classes must implement the [`Magento\Customer\CustomerData\SectionSourceInterface`]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Customer/CustomerData/SectionSourceInterface.php){:target="_blank"} interface.
21+
22+
The public method `getSectionData` must return an array with private data.
23+
24+
[Example]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/CustomerData/CompareProducts.php#L36-L45){:target="_blank"}
25+
26+
Add the following to your component's [dependency injection](https://glossary.magento.com/dependency-injection) configuration (`di.xml`):
27+
28+
```xml
29+
<type name="Magento\Customer\CustomerData\SectionPoolInterface">
30+
<arguments>
31+
<argument name="sectionSourceMap" xsi:type="array">
32+
<item name="custom-name" xsi:type="string">Vendor\ModuleName\CustomerData\ClassName</item>
33+
</argument>
34+
</arguments>
35+
</type>
36+
```
37+
38+
## Create a block and template {#config-cache-priv-how-block}
39+
40+
To render private content, create a block and a template to display user-agnostic data; this data is replaced with user-specific data by the [UI component](https://glossary.magento.com/ui-component).
41+
42+
{: .bs-callout-info }
43+
Do not use the `$_isScopePrivate` property in your blocks. This property is obsolete and will not work properly.
44+
45+
Replace private data in blocks with placeholders (using [Knockout](http://knockoutjs.com/documentation/introduction.html){:target="_blank"} syntax). The init scope on the root element is `data-bind="scope: 'compareProducts'"`, where you define the scope name (`compareProducts` in this example) in your [layout](https://glossary.magento.com/layout).
46+
47+
Initialize the component as follows:
48+
49+
```html
50+
<script type="text/x-magento-init">
51+
{"<css-selector>": {"Magento_Ui/js/core/app": <?php echo $block->getJsLayout();?>}}
52+
</script>
53+
```
54+
55+
[Example]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml#L46-L48){:target="_blank"}
56+
57+
## Configure a UI component {#config-cache-priv-how-ui}
58+
59+
The UI component renders block data on the Magento [storefront](https://glossary.magento.com/storefront). To initialize the UI component, you must call the initialization method `_super()`.
60+
61+
[Example]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js){:target="_blank"}
62+
63+
All properties are available in the template.
64+
65+
[Example of defining a UI component in a layout]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/view/frontend/layout/default.xml#L11-L22){:target="_blank"}
66+
67+
## Invalidate private content
68+
69+
Specify actions that trigger cache invalidation for private content blocks in a `sections.xml` configuration file in the `Vendor/ModuleName/etc/frontend` directory. Magento invalidates the cache on a POST or PUT request.
70+
71+
Customer sections was designed to cache private data in browser storage. This means that any customer section will no be updated until proper action was made.
72+
73+
The are some exception cases:
74+
75+
- Store and website switching, after any of these action customer section `cart` will be updated.
76+
- Customer cart lifetime option `section_data_lifetime` which is 60 minutes by default. After scheduled time passe section `cart` will be updated.
77+
78+
{: .bs-callout-info }
79+
Product information will not be simultaneously updated in customer cart (product name, price, product enabled/disabled). Information will be updated after what comes first: `section_data_lifetime` time passed or an action that the update cart triggered.
80+
81+
The following example adds comments to [app/code/Magento/Catalog/etc/frontend/sections.xml]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/etc/frontend/sections.xml){:target="_blank"} so you can see what the code is doing.
82+
83+
```xml
84+
<?xml version="1.0"?>
85+
<!--
86+
/**
87+
* Copyright © 2016 Magento. All rights reserved.
88+
* See COPYING.txt for license details.
89+
*/
90+
-->
91+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
92+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
93+
<!-- invalidates the "compare-products" section when a user
94+
adds a product to the comparison, resulting in a "catalog/product_compare/add" POST request -->
95+
<action name="catalog/product_compare/add">
96+
<section name="compare-products"/>
97+
</action>
98+
<!-- invalidates the section when a customer removes a product from the comparison -->
99+
<action name="catalog/product_compare/remove">
100+
<section name="compare-products"/>
101+
</action>
102+
<!-- invalidates the section when a customer clears all products from the comparison -->
103+
<action name="catalog/product_compare/clear">
104+
<section name="compare-products"/>
105+
</action>
106+
</config>
107+
```
108+
109+
{: .bs-callout .bs-callout-warning }
110+
Use only HTTP POST or PUT methods to change state (e.g., adding to a shopping cart, adding to a wishlist, etc.) and do not expect to see caching on these methods. Using GET or HEAD methods might trigger caching and prevent updates to private content. For more information about caching, see [RFC-2616 section 13](https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html){:target="_blank"}
111+
112+
Other examples:
113+
114+
- [Checkout]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Checkout/etc/frontend/sections.xml){:target="_blank"}
115+
- [Customer]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Customer/etc/frontend/sections.xml){:target="_blank"}
116+
117+
## Version private content {#config-priv-vers}
118+
119+
Private content, which is stored in the browser local storage, uses the `private_content_version` cookie to store the version.
120+
121+
Versioning works as follows:
122+
123+
1. The user performs some action, such as adding to a cart, that results in an POST or PUT request to the Magento application.
124+
1. The server generates the `private_content_version` cookie for this user and returns the response to the browser.
125+
1. Any future HTTP POST or PUT request changes the value of `private_content_version` and this version will be stored in the browser.
126+
127+
{: .bs-callout .bs-callout-warning }
128+
Please _note_ that the customer data ivalidation mechanism no longer relies on the `private_content_version`.
129+
130+
{% include cache/page-cache-checklists.md%}

guides/v2.3/graphql/caching.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ The definitions for some queries include cache tags. Full page caching uses thes
1111

1212
Magento caches the following queries:
1313

14-
* `category`
14+
* `category` (deprecated)
15+
* `categoryList`
1516
* `cmsBlocks`
1617
* `cmsPage`
1718
* `products`
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
group: graphql
3+
title: Filtering with custom attributes
4+
---
5+
6+
As of Magento 2.3.4, the `filter` attribute of the [`products`]({{page.baseurl}}/graphql/queries/products-234.html) query accepts the `ProductAttributeFilterInput` object. (In previous versions, the `filter` attribute required a `ProductFilterInput` object. This object contained a hard-coded list of filterable attributes, and you could not filter on a custom attribute or any other attribute that was not on the list.)
7+
8+
## Prerequisites
9+
10+
To enable a custom attribute (or any attribute that is not listed by default in the `ProductAttributeFilterInput` object) for filtering, select the attribute on the **Stores** > Attributes > **Product** page in the Admin and edit the following fields:
11+
12+
Field | Setting
13+
--- | ---
14+
**Use in Search** | Yes
15+
**Visible in Advanced Search** | Yes
16+
**Use in Layered Navigation** | Filterable (with results) or Filterable (no results)
17+
**Use in Search Results Layered Navigation** | Yes
18+
19+
## Define the filter for your query
20+
21+
The [`filter`]({{page.baseurl}}/graphql/queries/products-234.html#filter) definition for your custom attribute requires one of the following input data types:
22+
23+
- `FilterEqualTypeInput` - Specify this data type when the **Catalog Input Type for Store Owner** field for your custom attribute is set to Yes/No, Select, or Multiple select. Your filter can contain the `eq` or `in` attribute. Use the `eq` attribute to exactly match the specified string. Use the `in` attribute to filter on a comma-separated list of values.
24+
- `FilterMatchTypeInput` - Specify this data type when the the **Catalog Input Type for Store Owner** field for your custom attribute is set to Text Field or Text Area. Your filter must contain the `match` attribute, which will return all items that exactly match the specified string.
25+
- `FilterRangeTypeInput` - Specify this data type when the the **Catalog Input Type for Store Owner** field for your custom attribute is set to Price or Date. Your filter can contain one or both of the `to` and `from` attributes, which serve to provide a range of values to filter on.
26+
27+
## Example
28+
29+
In this example, the custom attribute `volume` was assigned to the `bags` attribute group. Running the [`customAttributeMetadata` query]({{page.baseurl}}/graphql/queries/custom-attribute-metadata.html) on this custom attribute reveals that the `label` and `value` values for the attribute's options are as follows:
30+
31+
`label` | `value`
32+
--- | ---
33+
`Large` | `216`
34+
`Medium` | `217`
35+
`Small` | `218`
36+
37+
In this scenario, a `products` search filtered to return items where the `volume` attribute is set to `Large` would be similar to the following:
38+
39+
**Request**
40+
41+
```graphql
42+
{
43+
products(filter: { volume: { eq: "216" } }) {
44+
total_count
45+
items {
46+
name
47+
sku
48+
}
49+
}
50+
}
51+
```
52+
53+
**Response**
54+
55+
The response might be similar to the following:
56+
57+
```json
58+
{
59+
"data": {
60+
"products": {
61+
"total_count": 1,
62+
"items": [
63+
{
64+
"name": "Wayfarer Messenger Bag",
65+
"sku": "24-MB05"
66+
}
67+
]
68+
}
69+
}
70+
}
71+
```
72+
73+
## Output attributes
74+
75+
When a product requires a filter attribute that is not a field on its output schema, inject the attribute name into the class in a module's `di.xml` file.
76+
77+
```xml
78+
<type name="Magento\CatalogGraphQl\Model\Resolver\Products\FilterArgument\ProductEntityAttributesForAst" >
79+
<arguments>
80+
<argument name="additionalAttributes" xsi:type="array">
81+
<item name="field_to_sort" xsi:type="string">field</item>
82+
<item name="other_field_to_sort" xsi:type="string">other_field</item>
83+
</argument>
84+
</arguments>
85+
</type>
86+
```
87+
88+
This example adds `field_to_sort` and `other_field_to_sort` attributes to the `additionalAttributes` array defined in the `ProductEntityAttributesForAst` class. The array already contains the `min_price`, `max_price`, and `category_ids` attributes.

guides/v2.3/graphql/develop/create-graphqls-file.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ The base `schema.graphqls` file, located in the `app/code/Magento/GraphQl/etc/`
2222

2323
A query definition can be one line, or it can be complex. If your module's query implements `searchCriteria`, then you must define arguments that define filters and pagination information, all of which adds complexity. However, if you expect a single result from your query, then its definition can be simple.
2424

25-
The following example shows the `products` query. The `type` is defined as a `Query`. The `products` definitions define the keywords that are used to construct a query, as shown in [Queries]({{ page.baseurl }}/graphql/queries/index.html). The parameter definitions will be discussed in [Specify output attributes](#specify-output-attributes).
25+
The following example shows the `products` query. The `type` is defined as a `Query`. The `products` definitions define the keywords that are used to construct a query, as shown in [Using queries]({{ page.baseurl }}/graphql/queries/index.html). The parameter definitions will be discussed in [Specify output attributes](#specify-output-attributes).
2626

2727
```text
2828
type Query {
2929
products (
30-
search: String,
31-
filter: ProductFilterInput,
32-
pageSize: Int = 20,
33-
currentPage: Int = 1,
34-
sort: ProductSortInput
30+
search: String
31+
filter: ProductAttributeFilterInput
32+
pageSize: Int = 20
33+
currentPage: Int = 1
34+
sort: ProductAttributeSortInput
3535
): Products @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Products")
3636
}
3737
```
@@ -99,11 +99,7 @@ url_key: String @doc(description: "The url key assigned to the product")
9999
product_count: Int @doc(description: "The number of products")
100100
```
101101

102-
Use the `@deprecated` directive to mark a query, mutation, or attribute as deprecated:
103-
104-
```text
105-
@deprecated(reason: "description")
106-
```
102+
Use the `@deprecated` directive to deprecate attributes and enum values. The GraphQL specification does not permit deprecating input values or arguments. The `reason` keyword allows you to specify which attribute/field or enum value should be used instead.
107103

108104
For example:
109105

guides/v2.3/graphql/mutations/set-payment-place-order.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ redirect from:
77
- /guides/v2.3/graphql/reference/quote-set-payment-place-order.html
88
---
99

10-
{:.bs-callout-note} The `setPaymentMethodAndPlaceOrder` mutation will be deprecated in the next patch release. Use the `setPaymentMethodOnCart` and `placeOrder` mutations instead. You can run the two methods in the same call if your use case allows it.
10+
{:.bs-callout-warning}
11+
The `setPaymentMethodAndPlaceOrder` mutation has been deprecated. Use the [setPaymentMethodOnCart]({{page.baseurl}}/graphql/mutations/set-payment-method.html) and [placeOrder]({{page.baseurl}}/graphql/mutations/place-order.html) mutations instead. You can run the two methods in the same call if your use case allows it.
1112

1213
The `setPaymentMethodAndPlaceOrder` mutation sets the cart payment method and converts the cart into an order. The
1314
mutation returns the resulting order ID. You cannot manage orders with GraphQL, because orders are part of the backend.

0 commit comments

Comments
 (0)