Skip to content

Commit 356ad60

Browse files
committed
Merge branch 'MAGETWO-91731' into 2.3-develop-pr8
2 parents 56b6f42 + 932ee93 commit 356ad60

File tree

8 files changed

+99
-6
lines changed

8 files changed

+99
-6
lines changed

app/code/Magento/Wishlist/Helper/Data.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public function getWishlist()
195195

196196
/**
197197
* Retrieve wishlist item count (include config settings)
198+
*
198199
* Used in top link menu only
199200
*
200201
* @return int
@@ -450,6 +451,8 @@ public function getSharedAddAllToCartUrl()
450451
}
451452

452453
/**
454+
* Get cart URL parameters
455+
*
453456
* @param string|\Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
454457
* @return array
455458
*/
@@ -576,7 +579,7 @@ public function calculate()
576579
) {
577580
$count = $collection->getItemsQty();
578581
} else {
579-
$count = $collection->getSize();
582+
$count = $collection->count();
580583
}
581584
$this->_customerSession->setWishlistDisplayType(
582585
$this->scopeConfig->getValue(

app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ protected function _assignProducts()
307307

308308
$checkInStock = $this->_productInStock && !$this->stockConfiguration->isShowOutOfStock();
309309

310+
/** @var \Magento\Wishlist\Model\Item $item */
310311
foreach ($this as $item) {
311312
$product = $productCollection->getItemById($item->getProductId());
312313
if ($product) {
@@ -320,7 +321,7 @@ protected function _assignProducts()
320321
$item->setPrice($product->getPrice());
321322
}
322323
} else {
323-
$item->isDeleted(true);
324+
$this->removeItemByKey($item->getId());
324325
}
325326
}
326327

@@ -418,6 +419,7 @@ public function setVisibilityFilter($flag = true)
418419

419420
/**
420421
* Set Salable Filter.
422+
*
421423
* This filter apply Salable Product Types Filter to product collection.
422424
*
423425
* @param bool $flag
@@ -431,6 +433,7 @@ public function setSalableFilter($flag = true)
431433

432434
/**
433435
* Set In Stock Filter.
436+
*
434437
* This filter remove items with no salable product.
435438
*
436439
* @param bool $flag
@@ -567,6 +570,8 @@ public function getItemsQty()
567570
}
568571

569572
/**
573+
* After load data
574+
*
570575
* @return $this
571576
*/
572577
protected function _afterLoadData()

app/code/Magento/Wishlist/Model/Wishlist.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ public function addItem(Item $item)
380380

381381
/**
382382
* Adds new product to wishlist.
383+
*
383384
* Returns new item or string on error.
384385
*
385386
* @param int|\Magento\Catalog\Model\Product $product
@@ -581,7 +582,7 @@ public function setStore($store)
581582
*/
582583
public function getItemsCount()
583584
{
584-
return $this->getItemCollection()->getSize();
585+
return $this->getItemCollection()->count();
585586
}
586587

587588
/**

app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,12 @@
8585
<click selector="{{StorefrontFooterSection.switchStoreButton}}" stepKey="ClickSwitchStoreButtonOnDefaultStore"/>
8686
<click selector="{{StorefrontFooterSection.storeLink($$storeGroup.group[name]$$)}}" stepKey="SelectSecondStoreToSwitchOn"/>
8787
<!-- Verify that both products are visible in wishlist on both stores -->
88-
<see userInput="$$product.name$$" selector="{{StorefrontCustomerWishlistSection.productItemNameText}}" stepKey="seeProduct1InWishlist"/>
8988
<amOnPage url="$$secondProduct.name$$.html" stepKey="navigateToProductPageOnSecondStore"/>
9089
<see userInput="$$secondProduct.name$$" selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="assertSecondProductNameTitle"/>
9190
<click selector="{{StorefrontProductPageSection.addToWishlist}}" stepKey="addSecondProductToWishlist"/>
92-
<see userInput="$$product.name$$" selector="{{StorefrontCustomerWishlistSection.productItemNameText}}" stepKey="seeProduct1InWishlistOnSecondStore"/>
9391
<see userInput="$$secondProduct.name$$" selector="{{StorefrontCustomerWishlistSection.productItemNameText}}" stepKey="seeProduct2InWishlistOnSecondStore"/>
9492
<click selector="{{StorefrontFooterSection.switchStoreButton}}" stepKey="ClickSwitchStoreButtonOnSecondStore"/>
9593
<click selector="{{StorefrontFooterSection.storeLink('Main Website Store')}}" stepKey="SelectDefaultStoreToSwitchOn"/>
9694
<see userInput="$$product.name$$" selector="{{StorefrontCustomerWishlistSection.productItemNameText}}" stepKey="seeProduct1InWishlistOnDefaultStore"/>
97-
<see userInput="$$secondProduct.name$$" selector="{{StorefrontCustomerWishlistSection.productItemNameText}}" stepKey="seeProduct2InWishlistOnDefaultStore"/>
9895
</test>
9996
</tests>

dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function testAddActionProductNameXss()
122122
}
123123

124124
/**
125+
* @magentoDbIsolation disabled
125126
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php
126127
*/
127128
public function testAllcartAction()

dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Wishlist\Model;
77

88
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
910
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\DataObject;
1112

@@ -85,4 +86,39 @@ public function testAddNewItemInvalidWishlistItemConfiguration()
8586
);
8687
$this->wishlist->addNewItem($product);
8788
}
89+
90+
/**
91+
* @magentoDbIsolation disabled
92+
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
93+
*/
94+
public function testGetItemCollection()
95+
{
96+
$productSku = 'simple';
97+
$customerId = 1;
98+
99+
$this->wishlist->loadByCustomerId($customerId, true);
100+
$itemCollection = $this->wishlist->getItemCollection();
101+
/** @var \Magento\Wishlist\Model\Item $item */
102+
$item = $itemCollection->getFirstItem();
103+
$this->assertEquals($productSku, $item->getProduct()->getSku());
104+
}
105+
106+
/**
107+
* @magentoDbIsolation disabled
108+
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
109+
*/
110+
public function testGetItemCollectionWithDisabledProduct()
111+
{
112+
$productSku = 'simple';
113+
$customerId = 1;
114+
115+
$productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
116+
$product = $productRepository->get($productSku);
117+
$product->setStatus(ProductStatus::STATUS_DISABLED);
118+
$productRepository->save($product);
119+
120+
$this->wishlist->loadByCustomerId($customerId, true);
121+
$itemCollection = $this->wishlist->getItemCollection();
122+
$this->assertEmpty($itemCollection->getItems());
123+
}
88124
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
9+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
10+
11+
/** @var \Magento\Framework\Registry $registry */
12+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
13+
$registry->unregister('isSecureArea');
14+
$registry->register('isSecureArea', true);
15+
16+
/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
17+
$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
18+
$wishlist->loadByCustomerId(1);
19+
$wishlist->delete();
20+
21+
$registry->unregister('isSecureArea');
22+
$registry->register('isSecureArea', false);
23+
24+
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_rollback.php';
25+
require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
9+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
10+
11+
/** @var \Magento\Framework\Registry $registry */
12+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
13+
$registry->unregister('isSecureArea');
14+
$registry->register('isSecureArea', true);
15+
16+
/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
17+
$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
18+
$wishlist->loadByCustomerId(1);
19+
$wishlist->delete();
20+
21+
$registry->unregister('isSecureArea');
22+
$registry->register('isSecureArea', false);
23+
24+
require __DIR__ . '/../../../Magento/Catalog/_files/product_special_price_rollback.php';
25+
require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';

0 commit comments

Comments
 (0)