Skip to content

Commit e3593ae

Browse files
committed
Merge pull request #53 from magento-south/BUGS
[SOUTH] Bugfixes
2 parents dc3aee6 + 4f0cfcd commit e3593ae

File tree

8 files changed

+155
-15
lines changed

8 files changed

+155
-15
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,10 @@ public function reindex()
10861086
$flatIndexer->reindexRow($this->getId());
10871087
}
10881088
}
1089-
$affectedProductIds = $this->getAffectedProductIds();
10901089
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
1091-
if (!$productIndexer->isScheduled() && !empty($affectedProductIds)) {
1090+
if (!$productIndexer->isScheduled()
1091+
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
1092+
) {
10921093
$productIndexer->reindexList($this->getPathIds());
10931094
}
10941095
}

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

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,21 +380,37 @@ public function testReindexFlatEnabled($flatScheduled, $productScheduled, $expec
380380
public function reindexFlatDisabledTestDataProvider()
381381
{
382382
return [
383-
'set 1' => [false, 1],
384-
'set 2' => [true, 0],
383+
[false, null, null, null, 0],
384+
[true, null, null, null, 0],
385+
[false, [], null, null, 0],
386+
[false, ["1", "2"], null, null, 1],
387+
[false, null, 1, null, 1],
388+
[false, ["1", "2"], 0, 1, 1],
389+
[false, null, 1, 1, 0],
385390
];
386391
}
387392

388393
/**
389-
* @param $productScheduled
390-
* @param $expectedProductReindexCall
394+
* @param bool $productScheduled
395+
* @param array $affectedIds
396+
* @param int|string $isAnchorOrig
397+
* @param int|string $isAnchor
398+
* @param int $expectedProductReindexCall
391399
*
392400
* @dataProvider reindexFlatDisabledTestDataProvider
393401
*/
394-
public function testReindexFlatDisabled($productScheduled, $expectedProductReindexCall)
395-
{
396-
$affectedProductIds = ["1", "2"];
397-
$this->category->setAffectedProductIds($affectedProductIds);
402+
public function testReindexFlatDisabled(
403+
$productScheduled,
404+
$affectedIds,
405+
$isAnchorOrig,
406+
$isAnchor,
407+
$expectedProductReindexCall
408+
) {
409+
$this->category->setAffectedProductIds($affectedIds);
410+
$this->category->setData('is_anchor', $isAnchor);
411+
$this->category->setOrigData('is_anchor', $isAnchorOrig);
412+
$this->category->setAffectedProductIds($affectedIds);
413+
398414
$pathIds = ['path/1/2', 'path/2/3'];
399415
$this->category->setData('path_ids', $pathIds);
400416
$this->category->setId('123');
@@ -403,8 +419,12 @@ public function testReindexFlatDisabled($productScheduled, $expectedProductReind
403419
->method('isFlatEnabled')
404420
->will($this->returnValue(false));
405421

406-
$this->productIndexer->expects($this->exactly(1))->method('isScheduled')->will($this->returnValue($productScheduled));
407-
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))->method('reindexList')->with($pathIds);
422+
$this->productIndexer->expects($this->exactly(1))
423+
->method('isScheduled')
424+
->willReturn($productScheduled);
425+
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))
426+
->method('reindexList')
427+
->with($pathIds);
408428

409429
$this->indexerRegistry->expects($this->at(0))
410430
->method('get')

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ define([
5252
customer = customerData.get('customer');
5353

5454
if (!customer().firstname && !cart().isGuestCheckoutAllowed) {
55-
authenticationPopup.showModal();
55+
if (this.options.url.isRedirectRequired) {
56+
location.href = this.options.url.loginUrl;
57+
} else {
58+
authenticationPopup.showModal();
59+
}
5660

5761
return false;
5862
}

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ define([
3333
"url": {
3434
"checkout": window.checkout.checkoutUrl,
3535
"update": window.checkout.updateItemQtyUrl,
36-
"remove": window.checkout.removeItemUrl
36+
"remove": window.checkout.removeItemUrl,
37+
"loginUrl": window.checkout.customerLoginUrl,
38+
"isRedirectRequired": window.checkout.isRedirectRequired
3739
},
3840
"button": {
3941
"checkout": "#top-cart-btn-checkout",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model\Cart;
7+
8+
use Magento\Customer\Model\Checkout\ConfigProvider;
9+
10+
class ConfigPlugin
11+
{
12+
/**
13+
* @var ConfigProvider
14+
*/
15+
protected $configProvider;
16+
17+
/**
18+
* @param ConfigProvider $configProvider
19+
*/
20+
public function __construct(
21+
ConfigProvider $configProvider
22+
) {
23+
$this->configProvider = $configProvider;
24+
}
25+
26+
/**
27+
* @param \Magento\Checkout\Block\Cart\Sidebar $subject
28+
* @param array $result
29+
* @return array
30+
*
31+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
32+
*/
33+
public function afterGetConfig(\Magento\Checkout\Block\Cart\Sidebar $subject, array $result)
34+
{
35+
return array_merge_recursive($result, $this->configProvider->getConfig());
36+
}
37+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model\Checkout;
7+
8+
use Magento\Checkout\Model\ConfigProviderInterface;
9+
use Magento\Customer\Model\Url;
10+
use Magento\Framework\UrlInterface;
11+
use Magento\Store\Model\StoreManagerInterface;
12+
13+
class ConfigProvider implements ConfigProviderInterface
14+
{
15+
/**
16+
* @var StoreManagerInterface
17+
*/
18+
protected $storeManager;
19+
20+
/**
21+
* @var UrlInterface
22+
*/
23+
protected $urlBuilder;
24+
25+
/**
26+
* @param UrlInterface $urlBuilder
27+
* @param StoreManagerInterface $storeManager
28+
*/
29+
public function __construct(
30+
UrlInterface $urlBuilder,
31+
StoreManagerInterface $storeManager
32+
) {
33+
$this->urlBuilder = $urlBuilder;
34+
$this->storeManager = $storeManager;
35+
}
36+
37+
/**
38+
* {@inheritdoc}
39+
*/
40+
public function getConfig()
41+
{
42+
return [
43+
'customerLoginUrl' => $this->getLoginUrl(),
44+
'isRedirectRequired' => $this->isRedirectRequired(),
45+
];
46+
}
47+
48+
/**
49+
* Returns URL to login controller action
50+
*
51+
* @return string
52+
*/
53+
protected function getLoginUrl()
54+
{
55+
return $this->urlBuilder->getUrl(Url::ROUTE_ACCOUNT_LOGIN);
56+
}
57+
58+
/**
59+
* Whether redirect to login page is required
60+
*
61+
* @return bool
62+
*/
63+
protected function isRedirectRequired()
64+
{
65+
$baseUrl = $this->storeManager->getStore()->getBaseUrl();
66+
67+
if (strpos($this->getLoginUrl(), $baseUrl) !== false) {
68+
return false;
69+
}
70+
71+
return true;
72+
}
73+
}

app/code/Magento/Customer/etc/frontend/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@
5454
<type name="Magento\Customer\Controller\AccountInterface">
5555
<plugin name="customer_account" type="Magento\Customer\Controller\Plugin\Account" />
5656
</type>
57+
<type name="Magento\Checkout\Block\Cart\Sidebar">
58+
<plugin name="customer_cart" type="\Magento\Customer\Model\Cart\ConfigPlugin" />
59+
</type>
5760
</config>

app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ define([
6666
$('[data-action="add-to-wishlist"]').each(function(index, element) {
6767
var params = $(element).data('post');
6868
if (!params)
69-
params = {};
69+
params = {'data': {}};
7070

7171
if (!$.isEmptyObject(dataToAdd)) {
7272
self._removeExcessiveData(params, dataToAdd);

0 commit comments

Comments
 (0)