Skip to content

Commit 6ef9992

Browse files
merge magento/2.3-develop into magento-qwerty/MAGETWO-96975
2 parents 1924b7f + 85429d7 commit 6ef9992

File tree

88 files changed

+3223
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3223
-188
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
use Magento\Store\Model\ScopeInterface;
1818
use Magento\Store\Model\Store;
1919
use Magento\Store\Model\StoreManagerInterface;
20+
use Magento\Catalog\Helper\Data;
2021

2122
/**
2223
* Catalog product custom option resource model
2324
*
24-
* @author Magento Core Team <core@magentocommerce.com>
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2526
*/
2627
class Value extends AbstractDb
2728
{
@@ -51,6 +52,11 @@ class Value extends AbstractDb
5152
*/
5253
private $localeFormat;
5354

55+
/**
56+
* @var Data
57+
*/
58+
private $dataHelper;
59+
5460
/**
5561
* Class constructor
5662
*
@@ -59,17 +65,21 @@ class Value extends AbstractDb
5965
* @param StoreManagerInterface $storeManager
6066
* @param ScopeConfigInterface $config
6167
* @param string $connectionName
68+
* @param Data $dataHelper
6269
*/
6370
public function __construct(
6471
Context $context,
6572
CurrencyFactory $currencyFactory,
6673
StoreManagerInterface $storeManager,
6774
ScopeConfigInterface $config,
68-
$connectionName = null
75+
$connectionName = null,
76+
Data $dataHelper = null
6977
) {
7078
$this->_currencyFactory = $currencyFactory;
7179
$this->_storeManager = $storeManager;
7280
$this->_config = $config;
81+
$this->dataHelper = $dataHelper ?: ObjectManager::getInstance()
82+
->get(Data::class);
7383
parent::__construct($context, $connectionName);
7484
}
7585

@@ -131,7 +141,7 @@ protected function _saveValuePrices(AbstractModel $object)
131141
$optionTypeId = $this->getConnection()->fetchOne($select);
132142

133143
if ($optionTypeId) {
134-
if ($object->getStoreId() == '0') {
144+
if ($object->getStoreId() == '0' || $this->dataHelper->isPriceGlobal()) {
135145
$bind = ['price' => $price, 'price_type' => $priceType];
136146
$where = [
137147
'option_type_id = ?' => $optionTypeId,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Category;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
11+
12+
/**
13+
* Identity for multiple resolved categories
14+
*/
15+
class CategoriesIdentity implements IdentityInterface
16+
{
17+
/**
18+
* Get category IDs from resolved data
19+
*
20+
* @param array $resolvedData
21+
* @return string[]
22+
*/
23+
public function getIdentities(array $resolvedData): array
24+
{
25+
$ids = [];
26+
if (!empty($resolvedData)) {
27+
foreach ($resolvedData as $category) {
28+
$ids[] = $category['id'];
29+
}
30+
}
31+
return $ids;
32+
}
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Category;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
11+
12+
/**
13+
* Identity for resolved category
14+
*/
15+
class CategoryTreeIdentity implements IdentityInterface
16+
{
17+
/**
18+
* Get category ID from resolved data
19+
*
20+
* @param array $resolvedData
21+
* @return string[]
22+
*/
23+
public function getIdentities(array $resolvedData): array
24+
{
25+
return empty($resolvedData['id']) ? [] : [$resolvedData['id']];
26+
}
27+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Product;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
11+
12+
/**
13+
* Identity for resolved products
14+
*/
15+
class Identity implements IdentityInterface
16+
{
17+
/**
18+
* Get product ids for cache tag
19+
*
20+
* @param array $resolvedData
21+
* @return string[]
22+
*/
23+
public function getIdentities(array $resolvedData): array
24+
{
25+
$ids = [];
26+
$items = $resolvedData['items'] ?? [];
27+
foreach ($items as $item) {
28+
$ids[] = $item['entity_id'];
29+
}
30+
31+
return $ids;
32+
}
33+
}

app/code/Magento/CatalogGraphQl/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"suggest": {
1616
"magento/module-graph-ql": "*",
17+
"magento/module-graph-ql-cache": "*",
1718
"magento/module-store-graph-ql": "*"
1819
},
1920
"license": [

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ type Query {
99
currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1."),
1010
sort: ProductSortInput @doc(description: "Specifies which attribute to sort on, and whether to return the results in ascending or descending order.")
1111
): Products
12-
@resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Products") @doc(description: "The products query searches for products that match the criteria specified in the search and filter attributes")
12+
@resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Products") @doc(description: "The products query searches for products that match the criteria specified in the search and filter attributes") @cache(cacheTag: "cat_p", cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Identity")
1313
category (
1414
id: Int @doc(description: "Id of the category")
1515
): CategoryTree
16-
@resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree")
16+
@resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree") @doc(description: "The category query searches for categories that match the criteria specified in the search and filter attributes") @cache(cacheTag: "cat_c", cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoryTreeIdentity")
1717
}
1818

1919
enum CurrencyEnum @doc(description: "The list of available currency codes") {
@@ -275,7 +275,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
275275
price: ProductPrices @doc(description: "A ProductPrices object, indicating the price of an item") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Price")
276276
gift_message_available: String @doc(description: "Indicates whether a gift message is available")
277277
manufacturer: Int @doc(description: "A number representing the product's manufacturer")
278-
categories: [CategoryInterface] @doc(description: "The categories assigned to a product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Categories")
278+
categories: [CategoryInterface] @doc(description: "The categories assigned to a product") @cache(cacheTag: "cat_c", cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoriesIdentity") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Categories")
279279
canonical_url: String @doc(description: "Canonical URL") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CanonicalUrl")
280280
}
281281

@@ -396,7 +396,7 @@ interface CategoryInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model
396396
pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once. This attribute is optional."),
397397
currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1."),
398398
sort: ProductSortInput @doc(description: "Specifies which attribute to sort on, and whether to return the results in ascending or descending order.")
399-
): CategoryProducts @doc(description: "The list of products assigned to the category") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\Products")
399+
): CategoryProducts @doc(description: "The list of products assigned to the category") @cache(cacheTag: "cat_p", cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Identity") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\Products")
400400
breadcrumbs: [Breadcrumb] @doc(description: "Breadcrumbs, parent categories info") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\Breadcrumbs")
401401
}
402402

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CmsGraphQl\Model\Resolver\Block;
9+
10+
use Magento\Cms\Api\Data\BlockInterface;
11+
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
12+
13+
/**
14+
* Identity for resolved CMS block
15+
*/
16+
class Identity implements IdentityInterface
17+
{
18+
/**
19+
* Get block identities from resolved data
20+
*
21+
* @param array $resolvedData
22+
* @return string[]
23+
*/
24+
public function getIdentities(array $resolvedData): array
25+
{
26+
$ids = [];
27+
$items = $resolvedData['items'] ?? [];
28+
foreach ($items as $item) {
29+
if (is_array($item) && !empty($item[BlockInterface::BLOCK_ID])) {
30+
$ids[] = $item[BlockInterface::BLOCK_ID];
31+
$ids[] = $item[BlockInterface::IDENTIFIER];
32+
}
33+
}
34+
35+
return $ids;
36+
}
37+
}

app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function getData(string $blockIdentifier): array
5959
$renderedContent = $this->widgetFilter->filter($block->getContent());
6060

6161
$blockData = [
62+
BlockInterface::BLOCK_ID => $block->getId(),
6263
BlockInterface::IDENTIFIER => $block->getIdentifier(),
6364
BlockInterface::TITLE => $block->getTitle(),
6465
BlockInterface::CONTENT => $renderedContent,

app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Page.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function __construct(
4040
}
4141

4242
/**
43+
* Get the page data
44+
*
4345
* @param int $pageId
4446
* @return array
4547
* @throws NoSuchEntityException
@@ -55,6 +57,7 @@ public function getData(int $pageId): array
5557
$renderedContent = $this->widgetFilter->filter($page->getContent());
5658

5759
$pageData = [
60+
PageInterface::PAGE_ID => $page->getId(),
5861
'url_key' => $page->getIdentifier(),
5962
PageInterface::TITLE => $page->getTitle(),
6063
PageInterface::CONTENT => $renderedContent,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CmsGraphQl\Model\Resolver\Page;
9+
10+
use Magento\Cms\Api\Data\PageInterface;
11+
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
12+
13+
/**
14+
* Identity for resolved CMS page
15+
*/
16+
class Identity implements IdentityInterface
17+
{
18+
/**
19+
* Get page ID from resolved data
20+
*
21+
* @param array $resolvedData
22+
* @return string[]
23+
*/
24+
public function getIdentities(array $resolvedData): array
25+
{
26+
return empty($resolvedData[PageInterface::PAGE_ID]) ? [] : [$resolvedData[PageInterface::PAGE_ID]];
27+
}
28+
}

0 commit comments

Comments
 (0)