Skip to content

Commit 31260b3

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-90301
2 parents 4f73250 + 92c3ac6 commit 31260b3

File tree

46 files changed

+742
-75
lines changed

Some content is hidden

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

46 files changed

+742
-75
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
<!--- Provide a general summary of the issue in the Title above -->
2-
<!--- Before adding new issues, please, check this article https://github.com/magento/magento2/wiki/Issue-reporting-guidelines-->
1+
<!---
2+
Thank you for contributing to Magento.
3+
To help us process this issue we recommend that you add the following information:
4+
- Summary of the issue,
5+
- Information on your environment,
6+
- Steps to reproduce,
7+
- Expected and actual results,
8+
9+
Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines
10+
-->
311

412
### Preconditions
5-
<!--- Provide a more detailed information of environment you use -->
6-
<!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. -->
13+
<!---
14+
Please provide as detailed information about your environment as possible.
15+
For example Magento version, tag, HEAD, PHP & MySQL version, etc..
16+
-->
717
1.
818
2.
919

1020
### Steps to reproduce
11-
<!--- Provide a set of unambiguous steps to reproduce this bug include code, if relevant -->
21+
<!---
22+
It is important to provide a set of clear steps to reproduce this bug.
23+
If relevant please include code samples
24+
-->
1225
1.
1326
2.
1427
3.
1528

1629
### Expected result
1730
<!--- Tell us what should happen -->
18-
1.
31+
1. [Screenshot, logs]
1932

2033
### Actual result
2134
<!--- Tell us what happens instead -->
2235
1. [Screenshot, logs]
23-
24-
<!--- (This may be platform independent comment) -->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
<!--- Provide a general summary of the Pull Request in the Title above -->
1+
<!---
2+
Thank you for contributing to Magento.
3+
To help us process this pull request we recommend that you add the following information:
4+
- Summary of the pull request,
5+
- Issue(s) related to the changes made,
6+
- Manual testing scenarios,
7+
-->
8+
9+
<!--- Please provide a general summary of the Pull Request in the Title above -->
210

311
### Description
4-
<!--- Provide a description of the changes proposed in the pull request -->
12+
<!---
13+
Please provide a description of the changes proposed in the pull request.
14+
Letting us know what has changed and why it needed changing will help us validate this pull request.
15+
-->
516

617
### Fixed Issues (if relevant)
7-
<!--- Provide a list of fixed issues in the format magento/magento2#<issue_number>, if relevant -->
18+
<!---
19+
If relevant, please provide a list of fixed issues in the format magento/magento2#<issue_number>.
20+
There could be 1 or more issues linked here and it will help us find some more information about the reasoning behind this change.
21+
-->
822
1. magento/magento2#<issue_number>: Issue title
923
2. ...
1024

1125
### Manual testing scenarios
12-
<!--- Provide a set of unambiguous steps to test the proposed code change -->
26+
<!---
27+
Please provide a set of unambiguous steps to test the proposed code change.
28+
Giving us manual testing scenarios will help with the processing and validation process.
29+
-->
1330
1. ...
1431
2. ...
1532

app/code/Magento/Braintree/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@
447447
<!-- PayPal value handlers infrastructure -->
448448
<type name="Magento\Braintree\Gateway\Response\PayPal\VaultDetailsHandler">
449449
<arguments>
450-
<argument name="paymentTokenFactory" xsi:type="object">Magento\Vault\Model\AccountPaymentTokenFactory</argument>
450+
<argument name="paymentTokenFactory" xsi:type="object">Magento\Vault\Api\Data\PaymentTokenFactoryInterface</argument>
451451
</arguments>
452452
</type>
453453
<virtualType name="BraintreePayPalValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">

app/code/Magento/Catalog/view/base/web/js/price-options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ define([
2020
optionConfig: {},
2121
optionHandlers: {},
2222
optionTemplate: '<%= data.label %>' +
23-
'<% if (data.finalPrice.value) { %>' +
23+
'<% if (data.finalPrice.value > 0) { %>' +
2424
' +<%- data.finalPrice.formatted %>' +
25+
'<% } else if (data.finalPrice.value < 0) { %>' +
26+
' <%- data.finalPrice.formatted %>' +
2527
'<% } %>',
2628
controlContainer: 'dd'
2729
};

app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
?>
1111
<?php $_total = $block->getItems()->getSize() ?>
1212
<?php if ($_total): ?>
13-
<a href="#" class="action print" title="<?= /* @escapeNotVerified */ __('Print This Page') ?>">
13+
<a href="#" class="action print hidden-print" title="<?= /* @escapeNotVerified */ __('Print This Page') ?>">
1414
<span><?= /* @escapeNotVerified */ __('Print This Page') ?></span>
1515
</a>
1616
<div class="table-wrapper comparison">
@@ -29,7 +29,7 @@
2929
<?php if ($_i++ == 0): ?>
3030
<th scope="row" class="cell label remove"><span><?= /* @escapeNotVerified */ __('Remove Product') ?></span></th>
3131
<?php endif; ?>
32-
<td class="cell remove product">
32+
<td class="cell remove product hidden-print">
3333
<?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?>
3434
<a href="#" data-post='<?= /* @escapeNotVerified */ $compareHelper->getPostDataRemove($_item) ?>'
3535
class="action delete" title="<?= /* @escapeNotVerified */ __('Remove Product') ?>">
@@ -59,7 +59,7 @@
5959
</strong>
6060
<?= $block->getReviewsSummaryHtml($_item, 'short') ?>
6161
<?= /* @escapeNotVerified */ $block->getProductPrice($_item, '-compare-list-top') ?>
62-
<div class="product-item-actions">
62+
<div class="product-item-actions hidden-print">
6363
<div class="actions-primary">
6464
<?php if ($_item->isSaleable()): ?>
6565
<form data-role="tocart-form" action="<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Product\Compare')->getAddToCartUrl($_item) ?>" method="post">
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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\Schema\Type\ResolveInfo;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Query\Resolver\Value;
13+
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
14+
use Magento\Framework\GraphQl\Query\ResolverInterface;
15+
16+
/**
17+
* Retrieves the sort fields data
18+
*/
19+
class SortFields implements ResolverInterface
20+
{
21+
/**
22+
* @var ValueFactory
23+
*/
24+
private $valueFactory;
25+
26+
/**
27+
* @var \Magento\Catalog\Model\Config
28+
*/
29+
private $catalogConfig;
30+
31+
/**
32+
* @var \Magento\Store\Model\StoreManagerInterface
33+
*/
34+
private $storeManager;
35+
36+
/**
37+
* @var \Magento\Catalog\Model\Category\Attribute\Source\Sortby
38+
*/
39+
private $sortbyAttributeSource;
40+
41+
/**
42+
* @param ValueFactory $valueFactory
43+
* @param \Magento\Catalog\Model\Config $catalogConfig
44+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
45+
* @oaram \Magento\Catalog\Model\Category\Attribute\Source\Sortby $sortbyAttributeSource
46+
*/
47+
public function __construct(
48+
ValueFactory $valueFactory,
49+
\Magento\Catalog\Model\Config $catalogConfig,
50+
\Magento\Store\Model\StoreManagerInterface $storeManager,
51+
\Magento\Catalog\Model\Category\Attribute\Source\Sortby $sortbyAttributeSource
52+
) {
53+
$this->valueFactory = $valueFactory;
54+
$this->catalogConfig = $catalogConfig;
55+
$this->storeManager = $storeManager;
56+
$this->sortbyAttributeSource = $sortbyAttributeSource;
57+
}
58+
59+
/**
60+
* {@inheritDoc}
61+
*/
62+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value
63+
{
64+
$sortFieldsOptions = $this->sortbyAttributeSource->getAllOptions();
65+
array_walk(
66+
$sortFieldsOptions,
67+
function (&$option) {
68+
$option['label'] = (string)$option['label'];
69+
}
70+
);
71+
$data = [
72+
'default' => $this->catalogConfig->getProductListDefaultSortBy($this->storeManager->getStore()->getId()),
73+
'options' => $sortFieldsOptions,
74+
];
75+
76+
$result = function () use ($data) {
77+
return $data;
78+
};
79+
80+
return $this->valueFactory->create($result);
81+
}
82+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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\Catalog\Model\Product;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Query\Resolver\Value;
13+
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
14+
use Magento\Framework\GraphQl\Query\ResolverInterface;
15+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
16+
17+
/**
18+
* Resolve data for product canonical URL
19+
*/
20+
class CanonicalUrl implements ResolverInterface
21+
{
22+
/**
23+
* @var ValueFactory
24+
*/
25+
private $valueFactory;
26+
27+
/**
28+
* @param ValueFactory $valueFactory
29+
*/
30+
public function __construct(
31+
ValueFactory $valueFactory
32+
) {
33+
$this->valueFactory = $valueFactory;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function resolve(
40+
Field $field,
41+
$context,
42+
ResolveInfo $info,
43+
array $value = null,
44+
array $args = null
45+
): Value {
46+
if (!isset($value['model'])) {
47+
$result = function () {
48+
return null;
49+
};
50+
return $this->valueFactory->create($result);
51+
}
52+
53+
/* @var $product Product */
54+
$product = $value['model'];
55+
$url = $product->getUrlModel()->getUrl($product, ['_ignore_category' => true]);
56+
$result = function () use ($url) {
57+
return $url;
58+
};
59+
60+
return $this->valueFactory->create($result);
61+
}
62+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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\Test\Unit\Model\Resolver\Product;
9+
10+
use Magento\CatalogGraphQl\Model\Resolver\Product\CanonicalUrl;
11+
use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator;
12+
use Magento\Framework\GraphQl\Query\Resolver\Value;
13+
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
15+
use Magento\Store\Model\StoreManagerInterface;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class CanonicalUrlTest extends TestCase
19+
{
20+
/**
21+
* @var ObjectManager
22+
*/
23+
private $objectManager;
24+
25+
/**
26+
* @var CanonicalUrl
27+
*/
28+
private $subject;
29+
30+
/**
31+
* @var \PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $mockValueFactory;
34+
35+
/**
36+
* @var \PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
private $mockStoreManager;
39+
40+
public function testReturnsNullWhenNoProductAvailable()
41+
{
42+
$mockField = $this->getMockBuilder(\Magento\Framework\GraphQl\Config\Element\Field::class)
43+
->disableOriginalConstructor()
44+
->getMock();
45+
$mockInfo = $this->getMockBuilder(\Magento\Framework\GraphQl\Schema\Type\ResolveInfo::class)
46+
->disableOriginalConstructor()
47+
->getMock();
48+
49+
$this->mockValueFactory->method('create')->with(
50+
$this->callback(
51+
function ($param) {
52+
return $param() === null;
53+
}
54+
)
55+
);
56+
57+
$this->subject->resolve($mockField, '', $mockInfo, [], []);
58+
}
59+
60+
protected function setUp()
61+
{
62+
parent::setUp();
63+
$this->objectManager = new ObjectManager($this);
64+
$this->mockStoreManager = $this->getMockBuilder(StoreManagerInterface::class)->getMock();
65+
$this->mockValueFactory = $this->getMockBuilder(ValueFactory::class)
66+
->disableOriginalConstructor()
67+
->getMock();
68+
69+
$this->mockValueFactory->method('create')->willReturn(
70+
$this->objectManager->getObject(
71+
Value::class,
72+
['callback' => function () {
73+
return '';
74+
}]
75+
)
76+
);
77+
78+
$mockProductUrlPathGenerator = $this->getMockBuilder(ProductUrlPathGenerator::class)
79+
->disableOriginalConstructor()
80+
->getMock();
81+
$mockProductUrlPathGenerator->method('getUrlPathWithSuffix')->willReturn('product_url.html');
82+
83+
$this->subject = $this->objectManager->getObject(
84+
CanonicalUrl::class,
85+
[
86+
'valueFactory' => $this->mockValueFactory,
87+
'storeManager' => $this->mockStoreManager,
88+
'productUrlPathGenerator' => $mockProductUrlPathGenerator
89+
]
90+
);
91+
}
92+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
279279
gift_message_available: String @doc(description: "Indicates whether a gift message is available")
280280
manufacturer: Int @doc(description: "A number representing the product's manufacturer")
281281
categories: [CategoryInterface] @doc(description: "The categories assigned to a product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category")
282+
canonical_url: String @doc(description: "Canonical URL") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CanonicalUrl")
282283
}
283284

284285
interface PhysicalProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description: "PhysicalProductInterface contains attributes specific to tangible products") {
@@ -402,6 +403,7 @@ type Products @doc(description: "The Products object is the top-level object ret
402403
page_info: SearchResultPageInfo @doc(description: "An object that includes the page_info and currentPage values specified in the query")
403404
total_count: Int @doc(description: "The number of products returned")
404405
filters: [LayerFilter] @doc(description: "Layered navigation filters array")
406+
sort_fields: SortFields @doc(description: "An object that includes the default sort field and all available sort fields") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\SortFields")
405407
}
406408

407409
input ProductFilterInput @doc(description: "ProductFilterInput defines the filters to be used in the search. A filter contains at least one attribute, a comparison operator, and the value that is being searched for.") {
@@ -521,3 +523,13 @@ interface LayerFilterItemInterface @typeResolver(class: "Magento\\CatalogGraphQl
521523
type LayerFilterItem implements LayerFilterItemInterface {
522524

523525
}
526+
527+
type SortField {
528+
value: String @doc(description: "Attribute code of sort field")
529+
label: String @doc(description: "Label of sort field")
530+
}
531+
532+
type SortFields @doc(description: "SortFields contains a default value for sort fields and all available sort fields") {
533+
default: String @doc(description: "Default value of sort fields")
534+
options: [SortField] @doc(description: "Available sort fields")
535+
}

0 commit comments

Comments
 (0)