Skip to content

Commit ff93d50

Browse files
authored
Merge pull request #5383 from magento-tango/Tango-PR-02-25-2020-23
Tango PR 02-25-2020 v2.3
2 parents 794c049 + c563cc6 commit ff93d50

File tree

41 files changed

+1291
-84
lines changed

Some content is hidden

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

41 files changed

+1291
-84
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\Catalog\ViewModel\Product\Listing;
9+
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
use Magento\Framework\App\ActionInterface;
12+
use Magento\Framework\Url\Helper\Data as UrlHelper;
13+
14+
/**
15+
* Check is available add to compare.
16+
*/
17+
class PreparePostData implements ArgumentInterface
18+
{
19+
/**
20+
* @var UrlHelper
21+
*/
22+
private $urlHelper;
23+
24+
/**
25+
* @param UrlHelper $urlHelper
26+
*/
27+
public function __construct(UrlHelper $urlHelper)
28+
{
29+
$this->urlHelper = $urlHelper;
30+
}
31+
32+
/**
33+
* Wrapper for the PostHelper::getPostData()
34+
*
35+
* @param string $url
36+
* @param array $data
37+
* @return array
38+
*/
39+
public function getPostData(string $url, array $data = []):array
40+
{
41+
if (!isset($data[ActionInterface::PARAM_NAME_URL_ENCODED])) {
42+
$data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl();
43+
}
44+
return ['action' => $url, 'data' => $data];
45+
}
46+
}

app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
<block class="Magento\Catalog\Block\Product\ProductList\Related" name="catalog.product.related" template="Magento_Catalog::product/list/items.phtml">
177177
<arguments>
178178
<argument name="type" xsi:type="string">related</argument>
179+
<argument name="view_model" xsi:type="object">Magento\Catalog\ViewModel\Product\Listing\PreparePostData</argument>
179180
</arguments>
180181
<block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="related.product.addto" as="addto">
181182
<block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
@@ -186,6 +187,7 @@
186187
<block class="Magento\Catalog\Block\Product\ProductList\Upsell" name="product.info.upsell" template="Magento_Catalog::product/list/items.phtml">
187188
<arguments>
188189
<argument name="type" xsi:type="string">upsell</argument>
190+
<argument name="view_model" xsi:type="object">Magento\Catalog\ViewModel\Product\Listing\PreparePostData</argument>
189191
</arguments>
190192
<block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="upsell.product.addto" as="addto">
191193
<block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"

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

Lines changed: 109 additions & 49 deletions
Large diffs are not rendered by default.

app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
<block class="Magento\Checkout\Block\Cart\Crosssell" name="checkout.cart.crosssell" template="Magento_Catalog::product/list/items.phtml" after="-" ifconfig="checkout/cart/crosssell_enabled">
190190
<arguments>
191191
<argument name="type" xsi:type="string">crosssell</argument>
192+
<argument name="view_model" xsi:type="object">Magento\Catalog\ViewModel\Product\Listing\PreparePostData</argument>
192193
</arguments>
193194
<block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="crosssell.product.addto" as="addto">
194195
<block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"

app/code/Magento/Checkout/view/frontend/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ var config = {
1212
sidebar: 'Magento_Checkout/js/sidebar',
1313
checkoutLoader: 'Magento_Checkout/js/checkout-loader',
1414
checkoutData: 'Magento_Checkout/js/checkout-data',
15-
proceedToCheckout: 'Magento_Checkout/js/proceed-to-checkout'
15+
proceedToCheckout: 'Magento_Checkout/js/proceed-to-checkout',
16+
catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart'
1617
}
1718
}
1819
};

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,14 +1240,8 @@ private function getCatalogConfig()
12401240
*/
12411241
public function isPossibleBuyFromList($product)
12421242
{
1243-
$isAllCustomOptionsDisplayed = true;
1244-
foreach ($this->getConfigurableAttributes($product) as $attribute) {
1245-
$eavAttribute = $attribute->getProductAttribute();
1246-
1247-
$isAllCustomOptionsDisplayed = ($isAllCustomOptionsDisplayed && $eavAttribute->getUsedInProductListing());
1248-
}
1249-
1250-
return $isAllCustomOptionsDisplayed;
1243+
//such cases already handled by add to cart action
1244+
return true;
12511245
}
12521246

12531247
/**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model\Indexer;
7+
8+
use Magento\Customer\Model\Customer;
9+
10+
/**
11+
* Customer indexer
12+
*/
13+
class Processor extends \Magento\Framework\Indexer\AbstractProcessor
14+
{
15+
const INDEXER_ID = Customer::CUSTOMER_GRID_INDEXER_ID;
16+
}

app/code/Magento/CustomerImportExport/Model/Import/CustomerComposite.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CustomerImportExport\Model\Import;
77

88
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
9+
use Magento\Customer\Model\Indexer\Processor;
910

1011
/**
1112
* Import entity customer combined model
@@ -148,6 +149,11 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
148149
*/
149150
protected $masterAttributeCode = 'email';
150151

152+
/**
153+
* @var Processor
154+
*/
155+
private $indexerProcessor;
156+
151157
/**
152158
* @param \Magento\Framework\Stdlib\StringUtils $string
153159
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -158,6 +164,7 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
158164
* @param \Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory $dataFactory
159165
* @param \Magento\CustomerImportExport\Model\Import\CustomerFactory $customerFactory
160166
* @param \Magento\CustomerImportExport\Model\Import\AddressFactory $addressFactory
167+
* @param Processor $indexerProcessor
161168
* @param array $data
162169
* @throws \Magento\Framework\Exception\LocalizedException
163170
*
@@ -173,6 +180,7 @@ public function __construct(
173180
\Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory $dataFactory,
174181
\Magento\CustomerImportExport\Model\Import\CustomerFactory $customerFactory,
175182
\Magento\CustomerImportExport\Model\Import\AddressFactory $addressFactory,
183+
Processor $indexerProcessor,
176184
array $data = []
177185
) {
178186
parent::__construct($string, $scopeConfig, $importFactory, $resourceHelper, $resource, $errorAggregator, $data);
@@ -230,6 +238,7 @@ public function __construct(
230238
} else {
231239
$this->_nextCustomerId = $resourceHelper->getNextAutoincrement($this->_customerEntity->getEntityTable());
232240
}
241+
$this->indexerProcessor = $indexerProcessor;
233242
}
234243

235244
/**
@@ -273,11 +282,12 @@ protected function _importData()
273282
$this->countItemsCreated += $this->_customerEntity->getCreatedItemsCount();
274283
$this->countItemsUpdated += $this->_customerEntity->getUpdatedItemsCount();
275284
$this->countItemsDeleted += $this->_customerEntity->getDeletedItemsCount();
276-
277285
if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE) {
278-
return $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
286+
$result = $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
287+
}
288+
if ($result) {
289+
$this->indexerProcessor->markIndexerAsInvalid();
279290
}
280-
281291
return $result;
282292
}
283293

app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\ImportExport\Model\Import\Source\Csv;
1616

1717
/**
18-
* Customer composite test
18+
* The test for Customer composite model
1919
*
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
*/
@@ -88,6 +88,12 @@ class CustomerCompositeTest extends \PHPUnit\Framework\TestCase
8888
*/
8989
protected $errorFactory;
9090

91+
/**
92+
* @var \Magento\Customer\Model\Indexer\Processor
93+
* |\PHPUnit\Framework\MockObject\MockObject
94+
*/
95+
private $indexerProcessor;
96+
9197
/**
9298
* Expected prepared data after method CustomerComposite::_prepareRowForDb
9399
*
@@ -141,6 +147,7 @@ protected function setUp()
141147
->getMock();
142148

143149
$this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
150+
$this->indexerProcessor = $this->createMock(\Magento\Customer\Model\Indexer\Processor::class);
144151
}
145152

146153
/**
@@ -159,6 +166,7 @@ protected function _createModelMock($data)
159166
$this->_dataFactory,
160167
$this->_customerFactory,
161168
$this->_addressFactory,
169+
$this->indexerProcessor,
162170
$data
163171
);
164172
}

app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ public function collectRates(RateRequest $request)
141141
}
142142
}
143143
$oldValue = $request->getPackageValue();
144-
$request->setPackageValue($oldValue - $freePackageValue);
144+
$newPackageValue = $oldValue - $freePackageValue;
145+
$request->setPackageValue($newPackageValue);
146+
$request->setPackageValueWithDiscount($newPackageValue);
145147
}
146148

147149
if (!$request->getConditionName()) {

0 commit comments

Comments
 (0)