Skip to content

Commit 5f30cc9

Browse files
author
Roman Lytvynenko
committed
Merge branches 'MC-36055' and 'MC-36090' of https://github.com/magento-mpi/magento2ce into 2.3-develop
3 parents 65f2d7a + 39b8774 + 55b3b03 commit 5f30cc9

File tree

10 files changed

+329
-12
lines changed

10 files changed

+329
-12
lines changed

app/code/Magento/Checkout/view/frontend/web/js/region-updater.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ define([
171171
// Populate state/province dropdown list if available or use input box
172172
if (this.options.regionJson[country]) {
173173
this._removeSelectOptions(regionList);
174-
regionsEntries = Object.entries(this.options.regionJson[country]);
174+
regionsEntries = _.pairs(this.options.regionJson[country]);
175175
regionsEntries.sort(function (a, b) {
176176
return a[1].name > b[1].name ? 1 : -1;
177177
});
@@ -202,7 +202,7 @@ define([
202202
regionList.hide();
203203
container.hide();
204204
} else {
205-
regionList.show();
205+
regionList.removeAttr('disabled').show();
206206
}
207207
}
208208

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Model\Adminhtml\ResourceModel\Item\Product;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
11+
use Magento\Wishlist\Model\ResourceModel\Item\Collection as WishlistItemCollection;
12+
use Magento\Wishlist\Model\ResourceModel\Item\Product\CollectionBuilderInterface;
13+
14+
/**
15+
* Wishlist items products collection builder for adminhtml area
16+
*/
17+
class CollectionBuilder implements CollectionBuilderInterface
18+
{
19+
/**
20+
* @inheritDoc
21+
*/
22+
public function build(WishlistItemCollection $wishlistItemCollection, Collection $productCollection): Collection
23+
{
24+
return $productCollection;
25+
}
26+
}

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\ObjectManager;
1212
use Magento\Framework\EntityManager\MetadataPool;
1313
use Magento\Sales\Model\ConfigInterface;
14+
use Magento\Wishlist\Model\ResourceModel\Item\Product\CollectionBuilderInterface;
1415

1516
/**
1617
* Wishlist item collection
@@ -157,6 +158,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
157158
* @var ConfigInterface
158159
*/
159160
private $salesConfig;
161+
/**
162+
* @var CollectionBuilderInterface
163+
*/
164+
private $productCollectionBuilder;
160165

161166
/**
162167
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
@@ -178,8 +183,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
178183
* @param \Magento\Framework\App\State $appState
179184
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
180185
* @param TableMaintainer|null $tableMaintainer
181-
* @param ConfigInterface|null $salesConfig
182-
*
186+
* @param ConfigInterface|null $salesConfig
187+
* @param CollectionBuilderInterface|null $productCollectionBuilder
183188
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
184189
*/
185190
public function __construct(
@@ -202,7 +207,8 @@ public function __construct(
202207
\Magento\Framework\App\State $appState,
203208
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
204209
TableMaintainer $tableMaintainer = null,
205-
ConfigInterface $salesConfig = null
210+
ConfigInterface $salesConfig = null,
211+
?CollectionBuilderInterface $productCollectionBuilder = null
206212
) {
207213
$this->stockConfiguration = $stockConfiguration;
208214
$this->_adminhtmlSales = $adminhtmlSales;
@@ -219,6 +225,8 @@ public function __construct(
219225
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
220226
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
221227
$this->salesConfig = $salesConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);
228+
$this->productCollectionBuilder = $productCollectionBuilder
229+
?: ObjectManager::getInstance()->get(CollectionBuilderInterface::class);
222230
}
223231

224232
/**
@@ -309,12 +317,10 @@ protected function _assignProducts()
309317
$productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
310318
}
311319

312-
$productCollection->addPriceData()
313-
->addTaxPercents()
314-
->addIdFilter($this->_productIds)
315-
->addAttributeToSelect($this->_wishlistConfig->getProductAttributes())
316-
->addOptionsToResult()
317-
->addUrlRewrite();
320+
$productCollection->addIdFilter($this->_productIds)
321+
->addAttributeToSelect($this->_wishlistConfig->getProductAttributes());
322+
323+
$productCollection = $this->productCollectionBuilder->build($this, $productCollection);
318324

319325
if ($this->_productSalable) {
320326
$productCollection = $this->_adminhtmlSales->applySalableProductTypesFilter($productCollection);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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\Model\ResourceModel\Item\Product;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
11+
use Magento\Wishlist\Model\ResourceModel\Item\Collection as WishlistItemCollection;
12+
13+
/**
14+
* Wishlist items products collection builder
15+
*/
16+
class CollectionBuilder implements CollectionBuilderInterface
17+
{
18+
/**
19+
* @inheritDoc
20+
*/
21+
public function build(WishlistItemCollection $wishlistItemCollection, Collection $productCollection): Collection
22+
{
23+
return $productCollection->addPriceData()
24+
->addTaxPercents()
25+
->addOptionsToResult()
26+
->addUrlRewrite();
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Model\ResourceModel\Item\Product;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
11+
use Magento\Wishlist\Model\ResourceModel\Item\Collection as WishlistItemCollection;
12+
13+
/**
14+
* Wishlist items products collection builder
15+
*/
16+
interface CollectionBuilderInterface
17+
{
18+
/**
19+
* Modify product collection
20+
*
21+
* @param WishlistItemCollection $wishlistItemCollection
22+
* @param Collection $productCollection
23+
* @return Collection
24+
*/
25+
public function build(WishlistItemCollection $wishlistItemCollection, Collection $productCollection): Collection;
26+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public function getItemCollection()
379379
$this
380380
)->addStoreFilter(
381381
$this->getSharedStoreIds()
382-
)->setVisibilityFilter();
382+
)->setVisibilityFilter($this->_useCurrentWebsite);
383383
}
384384

385385
return $this->_itemCollection;

app/code/Magento/Wishlist/etc/adminhtml/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424
<type name="Magento\Catalog\Model\ResourceModel\Product">
2525
<plugin name="cleanups_wishlist_item_after_product_delete" type="Magento\Wishlist\Plugin\Model\ResourceModel\Product" />
2626
</type>
27+
<preference for="Magento\Wishlist\Model\ResourceModel\Item\Product\CollectionBuilderInterface"
28+
type="Magento\Wishlist\Model\Adminhtml\ResourceModel\Item\Product\CollectionBuilder"/>
2729
</config>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,6 @@
7878
</argument>
7979
</arguments>
8080
</type>
81+
<preference for="Magento\Wishlist\Model\ResourceModel\Item\Product\CollectionBuilderInterface"
82+
type="Magento\Wishlist\Model\ResourceModel\Item\Product\CollectionBuilder"/>
8183
</config>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,27 @@ public function testUpdateNotExistingProductInWishList(): void
243243
$wishlist->updateItem($item, []);
244244
}
245245

246+
/**
247+
* Test that admin user should be able to update wishlist on second website
248+
*
249+
* @magentoAppArea adminhtml
250+
* @magentoDbIsolation disabled
251+
* @magentoDataFixture Magento/Wishlist/_files/wishlist_on_second_website.php
252+
*
253+
* @return void
254+
*/
255+
public function testUpdateWishListItemOnSecondWebsite(): void
256+
{
257+
$wishlist = $this->getWishlistByCustomerId->execute(1);
258+
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-2');
259+
$this->assertNotNull($item);
260+
$this->assertEquals(1, $item->getQty());
261+
$buyRequest = $this->dataObjectFactory->create(['data' => ['qty' => 2]]);
262+
$wishlist->updateItem($item->getId(), $buyRequest);
263+
$updatedItem = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-2');
264+
$this->assertEquals(2, $updatedItem->getQty());
265+
}
266+
246267
/**
247268
* Assert item in wish list.
248269
*

0 commit comments

Comments
 (0)