Skip to content

Commit 6b84cd3

Browse files
merge magento/2.3-develop into magento-epam/EPAM-PR-72
2 parents 600a047 + 8eb50bf commit 6b84cd3

File tree

97 files changed

+2560
-466
lines changed

Some content is hidden

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

97 files changed

+2560
-466
lines changed

app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderInterface;
1111
use Magento\Framework\Stdlib\ArrayManager;
12+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1213

1314
/**
1415
* SetPaymentMethod additional data provider model for Authorizenet payment method
@@ -36,10 +37,32 @@ public function __construct(
3637
*
3738
* @param array $data
3839
* @return array
40+
* @throws GraphQlInputException
3941
*/
4042
public function getData(array $data): array
4143
{
42-
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data) ?? [];
44+
if (!isset($data[self::PATH_ADDITIONAL_DATA])) {
45+
throw new GraphQlInputException(
46+
__('Required parameter "authorizenet_acceptjs" for "payment_method" is missing.')
47+
);
48+
}
49+
if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_descriptor'])) {
50+
throw new GraphQlInputException(
51+
__('Required parameter "opaque_data_descriptor" for "authorizenet_acceptjs" is missing.')
52+
);
53+
}
54+
if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_value'])) {
55+
throw new GraphQlInputException(
56+
__('Required parameter "opaque_data_value" for "authorizenet_acceptjs" is missing.')
57+
);
58+
}
59+
if (!isset($data[self::PATH_ADDITIONAL_DATA]['cc_last_4'])) {
60+
throw new GraphQlInputException(
61+
__('Required parameter "cc_last_4" for "authorizenet_acceptjs" is missing.')
62+
);
63+
}
64+
65+
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data);
4366
foreach ($additionalData as $key => $value) {
4467
$additionalData[$this->convertSnakeCaseToCamelCase($key)] = $value;
4568
unset($additionalData[$key]);

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function __construct(
3939
$this->locator = $locator;
4040
$this->arrayManager = $arrayManager;
4141
}
42-
42+
4343
/**
44-
* {@inheritdoc}
44+
* @inheritdoc
4545
*/
4646
public function modifyMeta(array $meta)
4747
{
@@ -64,7 +64,7 @@ public function modifyMeta(array $meta)
6464
$this->arrayManager->findPath(
6565
ProductAttributeInterface::CODE_PRICE,
6666
$meta,
67-
null,
67+
self::DEFAULT_GENERAL_PANEL . '/children',
6868
'children'
6969
) . static::META_CONFIG_PATH,
7070
$meta,
@@ -94,7 +94,7 @@ public function modifyMeta(array $meta)
9494
}
9595

9696
/**
97-
* {@inheritdoc}
97+
* @inheritdoc
9898
*/
9999
public function modifyData(array $data)
100100
{

app/code/Magento/Catalog/Block/Product/View/Details.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function getGroupSortedChildNames(string $groupName, string $callback): a
3737
$alias = $layout->getElementAlias($childName);
3838
$sortOrder = (int)$this->getChildData($alias, 'sort_order') ?? 0;
3939

40-
$childNamesSortOrder[$sortOrder] = $childName;
40+
$childNamesSortOrder[$childName] = $sortOrder;
4141
}
4242

43-
ksort($childNamesSortOrder, SORT_NUMERIC);
43+
asort($childNamesSortOrder, SORT_NUMERIC);
4444

45-
return $childNamesSortOrder;
45+
return array_keys($childNamesSortOrder);
4646
}
4747
}

app/code/Magento/Catalog/Model/Product.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,12 +832,14 @@ public function getStoreIds()
832832
if (!$this->hasStoreIds()) {
833833
$storeIds = [];
834834
if ($websiteIds = $this->getWebsiteIds()) {
835-
if ($this->_storeManager->isSingleStoreMode()) {
835+
if (!$this->isObjectNew() && $this->_storeManager->isSingleStoreMode()) {
836836
$websiteIds = array_keys($websiteIds);
837837
}
838838
foreach ($websiteIds as $websiteId) {
839839
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
840-
$storeIds = array_merge($storeIds, $websiteStores);
840+
foreach ($websiteStores as $websiteStore) {
841+
$storeIds []= $websiteStore;
842+
}
841843
}
842844
}
843845
$this->setStoreIds($storeIds);
@@ -920,9 +922,9 @@ public function beforeSave()
920922
//Validate changing of design.
921923
$userType = $this->getUserContext()->getUserType();
922924
if ((
923-
$userType === UserContextInterface::USER_TYPE_ADMIN
925+
$userType === UserContextInterface::USER_TYPE_ADMIN
924926
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION
925-
)
927+
)
926928
&& !$this->getAuthorization()->isAllowed('Magento_Catalog::edit_product_design')
927929
) {
928930
$this->setData('custom_design', $this->getOrigData('custom_design'));

app/code/Magento/Catalog/Model/Product/TierPriceManagement.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,19 @@ public function getList($sku, $customerGroupId)
182182
: $customerGroupId);
183183

184184
$prices = [];
185-
foreach ($product->getData('tier_price') as $price) {
186-
if ((is_numeric($customerGroupId) && (int) $price['cust_group'] === (int) $customerGroupId)
187-
|| ($customerGroupId === 'all' && $price['all_groups'])
188-
) {
189-
/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
190-
$tierPrice = $this->priceFactory->create();
191-
$tierPrice->setValue($price[$priceKey])
192-
->setQty($price['price_qty'])
193-
->setCustomerGroupId($cgi);
194-
$prices[] = $tierPrice;
185+
$tierPrices = $product->getData('tier_price');
186+
if ($tierPrices !== null) {
187+
foreach ($tierPrices as $price) {
188+
if ((is_numeric($customerGroupId) && (int) $price['cust_group'] === (int) $customerGroupId)
189+
|| ($customerGroupId === 'all' && $price['all_groups'])
190+
) {
191+
/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
192+
$tierPrice = $this->priceFactory->create();
193+
$tierPrice->setValue($price[$priceKey])
194+
->setQty($price['price_qty'])
195+
->setCustomerGroupId($cgi);
196+
$prices[] = $tierPrice;
197+
}
195198
}
196199
}
197200
return $prices;

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Api\ExtensibleDataInterface;
1414
use Magento\Framework\Api\ExtensionAttributesFactory;
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
16+
use Magento\Store\Model\StoreManagerInterface;
1617

1718
/**
1819
* Product Test
@@ -207,6 +208,11 @@ class ProductTest extends \PHPUnit\Framework\TestCase
207208
*/
208209
private $eavConfig;
209210

211+
/**
212+
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
213+
*/
214+
private $storeManager;
215+
210216
/**
211217
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
212218
*/
@@ -303,13 +309,13 @@ protected function setUp()
303309
->disableOriginalConstructor()
304310
->getMock();
305311

306-
$storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
312+
$this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
307313
->disableOriginalConstructor()
308314
->getMockForAbstractClass();
309-
$storeManager->expects($this->any())
315+
$this->storeManager->expects($this->any())
310316
->method('getStore')
311317
->will($this->returnValue($this->store));
312-
$storeManager->expects($this->any())
318+
$this->storeManager->expects($this->any())
313319
->method('getWebsite')
314320
->will($this->returnValue($this->website));
315321
$this->indexerRegistryMock = $this->createPartialMock(
@@ -394,7 +400,7 @@ protected function setUp()
394400
'extensionFactory' => $this->extensionAttributesFactory,
395401
'productPriceIndexerProcessor' => $this->productPriceProcessor,
396402
'catalogProductOptionFactory' => $optionFactory,
397-
'storeManager' => $storeManager,
403+
'storeManager' => $this->storeManager,
398404
'resource' => $this->resource,
399405
'registry' => $this->registry,
400406
'moduleManager' => $this->moduleManager,
@@ -450,6 +456,48 @@ public function testGetStoreIds()
450456
$this->assertEquals($expectedStoreIds, $this->model->getStoreIds());
451457
}
452458

459+
/**
460+
* @dataProvider getSingleStoreIds
461+
* @param bool $isObjectNew
462+
*/
463+
public function testGetStoreSingleSiteModelIds(
464+
bool $isObjectNew
465+
) {
466+
$websiteIDs = [0 => 2];
467+
$this->model->setWebsiteIds(
468+
!$isObjectNew ? $websiteIDs : array_flip($websiteIDs)
469+
);
470+
471+
$this->model->isObjectNew($isObjectNew);
472+
473+
$this->storeManager->expects(
474+
$this->exactly(
475+
(int) !$isObjectNew
476+
)
477+
)
478+
->method('isSingleStoreMode')
479+
->will($this->returnValue(true));
480+
481+
$this->website->expects(
482+
$this->once()
483+
)->method('getStoreIds')
484+
->will($this->returnValue($websiteIDs));
485+
486+
$this->assertEquals($websiteIDs, $this->model->getStoreIds());
487+
}
488+
489+
public function getSingleStoreIds()
490+
{
491+
return [
492+
[
493+
false
494+
],
495+
[
496+
true
497+
],
498+
];
499+
}
500+
453501
public function testGetStoreId()
454502
{
455503
$this->model->setStoreId(3);
@@ -1221,8 +1269,7 @@ public function testGetMediaGalleryImagesMerging()
12211269
{
12221270
$mediaEntries =
12231271
[
1224-
'images' =>
1225-
[
1272+
'images' => [
12261273
[
12271274
'value_id' => 1,
12281275
'file' => 'imageFile.jpg',

app/code/Magento/CatalogGraphQl/Model/Resolver/CategoryTree.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
use Magento\Catalog\Model\Category;
1111
use Magento\CatalogGraphQl\Model\Resolver\Category\CheckCategoryIsActive;
1212
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\ExtractDataFromCategoryTree;
13-
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1413
use Magento\Framework\GraphQl\Config\Element\Field;
15-
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1614
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1715
use Magento\Framework\GraphQl\Query\ResolverInterface;
16+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree as CategoryTreeDataProvider;
1818

1919
/**
2020
* Category tree field resolver, used for GraphQL request processing.
@@ -27,7 +27,7 @@ class CategoryTree implements ResolverInterface
2727
const CATEGORY_INTERFACE = 'CategoryInterface';
2828

2929
/**
30-
* @var \Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree
30+
* @var CategoryTreeDataProvider
3131
*/
3232
private $categoryTree;
3333

@@ -42,12 +42,12 @@ class CategoryTree implements ResolverInterface
4242
private $checkCategoryIsActive;
4343

4444
/**
45-
* @param \Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree $categoryTree
45+
* @param CategoryTreeDataProvider $categoryTree
4646
* @param ExtractDataFromCategoryTree $extractDataFromCategoryTree
4747
* @param CheckCategoryIsActive $checkCategoryIsActive
4848
*/
4949
public function __construct(
50-
\Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree $categoryTree,
50+
CategoryTreeDataProvider $categoryTree,
5151
ExtractDataFromCategoryTree $extractDataFromCategoryTree,
5252
CheckCategoryIsActive $checkCategoryIsActive
5353
) {
@@ -56,22 +56,6 @@ public function __construct(
5656
$this->checkCategoryIsActive = $checkCategoryIsActive;
5757
}
5858

59-
/**
60-
* Get category id
61-
*
62-
* @param array $args
63-
* @return int
64-
* @throws GraphQlInputException
65-
*/
66-
private function getCategoryId(array $args) : int
67-
{
68-
if (!isset($args['id'])) {
69-
throw new GraphQlInputException(__('"id for category should be specified'));
70-
}
71-
72-
return (int)$args['id'];
73-
}
74-
7559
/**
7660
* @inheritdoc
7761
*/
@@ -81,7 +65,9 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8165
return $value[$field->getName()];
8266
}
8367

84-
$rootCategoryId = $this->getCategoryId($args);
68+
$rootCategoryId = isset($args['id']) ? (int)$args['id'] :
69+
(int)$context->getExtensionAttributes()->getStore()->getRootCategoryId();
70+
8571
if ($rootCategoryId !== Category::TREE_ROOT_ID) {
8672
$this->checkCategoryIsActive->execute($rootCategoryId);
8773
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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;
9+
10+
use Magento\Framework\GraphQl\Config\Element\Field;
11+
use Magento\Framework\GraphQl\Query\ResolverInterface;
12+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
13+
14+
/**
15+
* Root category tree field resolver, used for GraphQL request processing.
16+
*/
17+
class RootCategoryId implements ResolverInterface
18+
{
19+
/**
20+
* @inheritdoc
21+
*/
22+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
23+
{
24+
return (int)$context->getExtensionAttributes()->getStore()->getRootCategoryId();
25+
}
26+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ type StoreConfig @doc(description: "The type contains information about a store
416416
grid_per_page : Int @doc(description: "Products per Page on Grid Default Value.")
417417
list_per_page : Int @doc(description: "Products per Page on List Default Value.")
418418
catalog_default_sort_by : String @doc(description: "Default Sort By.")
419+
root_category_id: Int @doc(description: "The ID of the root category") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\RootCategoryId")
419420
}
420421

421422
type ProductVideo @doc(description: "Contains information about a product video.") implements MediaGalleryInterface {

0 commit comments

Comments
 (0)