Skip to content

Commit 088bc10

Browse files
authored
ENGCOM-3569: fixed issue #19292 for 2.3-develop #19305
2 parents 6179261 + 42d1adb commit 088bc10

File tree

11 files changed

+225
-12
lines changed

11 files changed

+225
-12
lines changed

app/code/Magento/Wishlist/Block/Customer/Wishlist.php

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
*/
66

77
/**
8-
* Wishlist block customer items
9-
*
108
* @author Magento Core Team <core@magentocommerce.com>
119
*/
1210
namespace Magento\Wishlist\Block\Customer;
1311

1412
/**
13+
* Wishlist block customer items.
14+
*
1515
* @api
1616
* @since 100.0.2
1717
*/
@@ -29,6 +29,11 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
2929
*/
3030
protected $_helperPool;
3131

32+
/**
33+
* @var \Magento\Wishlist\Model\ResourceModel\Item\Collection
34+
*/
35+
protected $_collection;
36+
3237
/**
3338
* @var \Magento\Customer\Helper\Session\CurrentCustomer
3439
*/
@@ -78,14 +83,64 @@ protected function _prepareCollection($collection)
7883
}
7984

8085
/**
81-
* Preparing global layout
86+
* Paginate Wishlist Product Items collection
8287
*
8388
* @return void
89+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
90+
*/
91+
private function paginateCollection()
92+
{
93+
$page = $this->getRequest()->getParam("p", 1);
94+
$limit = $this->getRequest()->getParam("limit", 10);
95+
$this->_collection
96+
->setPageSize($limit)
97+
->setCurPage($page);
98+
}
99+
100+
/**
101+
* Retrieve Wishlist Product Items collection
102+
*
103+
* @return \Magento\Wishlist\Model\ResourceModel\Item\Collection
104+
*/
105+
public function getWishlistItems()
106+
{
107+
if ($this->_collection === null) {
108+
$this->_collection = $this->_createWishlistItemCollection();
109+
$this->_prepareCollection($this->_collection);
110+
$this->paginateCollection();
111+
}
112+
return $this->_collection;
113+
}
114+
115+
/**
116+
* Preparing global layout
117+
*
118+
* @return $this
84119
*/
85120
protected function _prepareLayout()
86121
{
87122
parent::_prepareLayout();
88123
$this->pageConfig->getTitle()->set(__('My Wish List'));
124+
$this->getChildBlock('wishlist_item_pager')
125+
->setUseContainer(
126+
true
127+
)->setShowAmounts(
128+
true
129+
)->setFrameLength(
130+
$this->_scopeConfig->getValue(
131+
'design/pagination/pagination_frame',
132+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
133+
)
134+
)->setJump(
135+
$this->_scopeConfig->getValue(
136+
'design/pagination/pagination_frame_skip',
137+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
138+
)
139+
)->setLimit(
140+
$this->getLimit()
141+
)
142+
->setCollection($this->getWishlistItems());
143+
return $this;
89144
}
90145

91146
/**
@@ -198,6 +253,7 @@ public function getAddToCartQty(\Magento\Wishlist\Model\Item $item)
198253

199254
/**
200255
* Get add all to cart params for POST request
256+
*
201257
* @return string
202258
*/
203259
public function getAddAllToCartParams()
@@ -209,7 +265,7 @@ public function getAddAllToCartParams()
209265
}
210266

211267
/**
212-
* @return string
268+
* @inheritdoc
213269
*/
214270
protected function _toHtml()
215271
{

app/code/Magento/Wishlist/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"magento/module-rss": "*",
1616
"magento/module-sales": "*",
1717
"magento/module-store": "*",
18+
"magento/module-theme": "*",
1819
"magento/module-ui": "*"
1920
},
2021
"suggest": {

app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</referenceBlock>
1414
<referenceContainer name="content">
1515
<block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="Magento_Wishlist::view.phtml" cacheable="false">
16+
<block class="Magento\Theme\Block\Html\Pager" name="wishlist_item_pager"/>
1617
<block class="Magento\Wishlist\Block\Rss\Link" name="wishlist.rss.link" template="Magento_Wishlist::rss/wishlist.phtml"/>
1718
<block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="Magento_Wishlist::item/list.phtml" cacheable="false">
1819
<block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="Magento_Wishlist::item/column/image.phtml" cacheable="false"/>

app/code/Magento/Wishlist/view/frontend/templates/view.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
?>
1111

1212
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()) : ?>
13+
<div class="toolbar wishlist-toolbar"><?= $block->getChildHtml('wishlist_item_pager'); ?></div>
1314
<?= ($block->getChildHtml('wishlist.rss.link')) ?>
1415
<form class="form-wishlist-items" id="wishlist-view-form"
1516
data-mage-init='{"wishlist":{
@@ -51,5 +52,6 @@
5152
<input name="entity" value="<%- data.entity %>">
5253
<% } %>
5354
</form>
54-
</script>
55+
</script>
56+
<div class="toolbar wishlist-toolbar"><br><?= $block->getChildHtml('wishlist_item_pager'); ?></div>
5557
<?php endif ?>

app/design/frontend/Magento/blank/Magento_Wishlist/web/css/source/_module.less

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@
88
// _____________________________________________
99

1010
& when (@media-common = true) {
11+
.toolbar {
12+
&.wishlist-toolbar {
13+
.limiter {
14+
float: right;
15+
}
16+
.main .pages {
17+
display: inline-block;
18+
position: relative;
19+
z-index: 0;
20+
}
21+
.toolbar-amount,
22+
.limiter {
23+
display: inline-block;
24+
z-index: 1;
25+
}
26+
}
27+
}
28+
1129
.form.wishlist.items {
1230
.actions-toolbar {
1331
&:extend(.abs-reset-left-margin all);

app/design/frontend/Magento/luma/Magento_Wishlist/web/css/source/_module.less

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@
88
// _____________________________________________
99

1010
& when (@media-common = true) {
11+
.toolbar {
12+
&.wishlist-toolbar {
13+
.limiter {
14+
float: right;
15+
}
16+
.main .pages {
17+
display: inline-block;
18+
position: relative;
19+
z-index: 0;
20+
}
21+
.toolbar-amount,
22+
.limiter {
23+
display: inline-block;
24+
z-index: 1;
25+
}
26+
}
27+
}
28+
1129
.form.wishlist.items {
1230
.actions-toolbar {
1331
&:extend(.abs-reset-left-margin all);
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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\Wishlist\Test\Block\Customer\Wishlist\Items;
9+
10+
use Magento\Mtf\Block\Block;
11+
use Magento\Mtf\Client\Locator;
12+
13+
/**
14+
* Pager block for wishlist items page.
15+
*/
16+
class TopToolbar extends Block
17+
{
18+
/**
19+
* Selector next active element
20+
*
21+
* @var string
22+
*/
23+
private $nextPageSelector = '.item.current + .item a';
24+
25+
/**
26+
* Selector first element
27+
*
28+
* @var string
29+
*/
30+
private $firstPageSelector = '.item>.page';
31+
32+
/**
33+
* Selector option element
34+
*
35+
* @var string
36+
*/
37+
private $optionSelector = './/option';
38+
39+
/**
40+
* Go to the next page
41+
*
42+
* @return bool
43+
*/
44+
public function nextPage()
45+
{
46+
$nextPageItem = $this->_rootElement->find($this->nextPageSelector);
47+
if ($nextPageItem->isVisible()) {
48+
$nextPageItem->click();
49+
return true;
50+
}
51+
return false;
52+
}
53+
54+
/**
55+
* Go to the first page
56+
*
57+
* @return bool
58+
*/
59+
public function firstPage()
60+
{
61+
$firstPageItem = $this->_rootElement->find($this->firstPageSelector);
62+
if ($firstPageItem->isVisible()) {
63+
$firstPageItem->click();
64+
return true;
65+
}
66+
return false;
67+
}
68+
69+
/**
70+
* Set value for limiter element by index
71+
*
72+
* @param int $index
73+
* @return $this
74+
*/
75+
public function setLimiterValueByIndex($index)
76+
{
77+
$options = $this->_rootElement->getElements($this->optionSelector, Locator::SELECTOR_XPATH);
78+
if (isset($options[$index])) {
79+
$options[$index]->click();
80+
}
81+
return $this;
82+
}
83+
84+
/**
85+
* Get value for limiter element by index
86+
*
87+
* @param int $index
88+
* @return int|null
89+
*/
90+
public function getLimitedValueByIndex($index)
91+
{
92+
$options = $this->_rootElement->getElements($this->optionSelector, Locator::SELECTOR_XPATH);
93+
if (isset($options[$index])) {
94+
return $options[$index]->getValue();
95+
}
96+
return null;
97+
}
98+
}

dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsPresentInWishlist.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public function processAssert(
3636
$cmsIndex->getLinksBlock()->openLink('My Account');
3737
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
3838

39+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
40+
->isVisible();
41+
while (!$isProductVisible && $wishlistIndex->getTopToolbar()->nextPage()) {
42+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
43+
->isVisible();
44+
}
45+
3946
\PHPUnit\Framework\Assert::assertTrue(
4047
$wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)->isVisible(),
4148
$product->getName() . ' is not visible on Wish List page.'

dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductRegularPriceOnStorefront.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function processAssert(
4444
$cmsIndex->getLinksBlock()->openLink('My Account');
4545
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
4646

47+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
48+
->isVisible();
49+
while (!$isProductVisible && $wishlistIndex->getTopToolbar()->nextPage()) {
50+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
51+
->isVisible();
52+
}
53+
4754
$productRegularPrice = 0;
4855
if ($product instanceof GroupedProduct) {
4956
$associatedProducts = $product->getAssociated();
@@ -75,13 +82,17 @@ public function processAssert(
7582
}
7683

7784
$productItem = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product);
78-
$wishListProductRegularPrice = (float)$productItem->getRegularPrice();
85+
$wishListProductRegularPrice = $product instanceof BundleProduct
86+
? (float)$productItem->getPrice()
87+
: (float)$productItem->getRegularPrice();
7988

80-
\PHPUnit\Framework\Assert::assertEquals(
81-
$this->regularPriceLabel,
82-
$productItem->getPriceLabel(),
83-
'Wrong product regular price is displayed.'
84-
);
89+
if (!$product instanceof BundleProduct) {
90+
\PHPUnit\Framework\Assert::assertEquals(
91+
$this->regularPriceLabel,
92+
$productItem->getPriceLabel(),
93+
'Wrong product regular price is displayed.'
94+
);
95+
}
8596

8697
\PHPUnit\Framework\Assert::assertNotEmpty(
8798
$wishListProductRegularPrice,

dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<page name="WishlistIndex" mca="wishlist/index/index" module="Magento_Wishlist">
1010
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".messages" strategy="css selector"/>
1111
<block name="wishlistBlock" class="Magento\Wishlist\Test\Block\Customer\Wishlist" locator="#wishlist-view-form" strategy="css selector"/>
12+
<block name="topToolbar" class="Magento\Wishlist\Test\Block\Customer\Wishlist\Items\TopToolbar" locator=".//*[contains(@class,'wishlist-toolbar')][2]" strategy="xpath"/>
1213
</page>
1314
</config>

0 commit comments

Comments
 (0)