Skip to content

Commit 7858c6e

Browse files
committed
MAGETWO-64175: Merge branch 'MAGETWO-64175' of github.com:magento-engcom/magento2ce into develop-prs
2 parents 70e3a27 + 2db32a7 commit 7858c6e

File tree

3 files changed

+81
-11
lines changed

3 files changed

+81
-11
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,20 +284,10 @@ protected function _assignProducts()
284284
$productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
285285
}
286286

287-
$attributesToSelect = [
288-
'name',
289-
'visibility',
290-
'small_image',
291-
'thumbnail',
292-
'links_purchased_separately',
293-
'links_title',
294-
'price_type'
295-
];
296-
297287
$productCollection->addPriceData()
298288
->addTaxPercents()
299289
->addIdFilter($this->_productIds)
300-
->addAttributeToSelect($attributesToSelect)
290+
->addAttributeToSelect($this->_wishlistConfig->getProductAttributes())
301291
->addOptionsToResult()
302292
->addUrlRewrite();
303293

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
99
<group name="wishlist_item">
10+
<attribute name="name"/>
11+
<attribute name="small_image"/>
12+
<attribute name="thumbnail"/>
13+
<attribute name="links_purchased_separately"/>
14+
<attribute name="links_title"/>
15+
<attribute name="price_type"/>
1016
<attribute name="visibility"/>
1117
<attribute name="url_path"/>
1218
<attribute name="url_key"/>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Wishlist\Model\ResourceModel\Item;
8+
9+
use Magento\Catalog\Model\Product;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Wishlist\Model\Wishlist;
12+
use Magento\Catalog\Model\Attribute\Config;
13+
14+
class CollectionTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @var ObjectManager
18+
*/
19+
private $objectManager;
20+
21+
/**
22+
* @var Collection
23+
*/
24+
private $itemCollection;
25+
26+
/**
27+
* @var Wishlist
28+
*/
29+
private $wishlist;
30+
31+
/**
32+
* @var Config\Data
33+
*/
34+
private $attributeConfig;
35+
36+
protected function setUp()
37+
{
38+
$this->objectManager = ObjectManager::getInstance();
39+
$this->wishlist = $this->objectManager->create(Wishlist::class);
40+
$this->itemCollection = $this->objectManager->get(Collection::class);
41+
$this->attributeConfig = $this->objectManager->get(Config\Data::class);
42+
}
43+
44+
/**
45+
* Verify that Wishlist Item Collection uses Catalog Attributes defined in the configuration.
46+
*
47+
* @magentoDataFixture Magento/Wishlist/_files/wishlist_shared.php
48+
* @magentoAppIsolation enabled
49+
* @magentoDbIsolation enabled
50+
*/
51+
public function testLoadedProductAttributes()
52+
{
53+
$this->addAttributesToWishlistConfig([
54+
'short_description',
55+
]);
56+
$this->wishlist->loadByCode('fixture_unique_code');
57+
$this->itemCollection->addWishlistFilter($this->wishlist);
58+
59+
/** @var Product $productOnWishlist */
60+
$productOnWishlist = $this->itemCollection->getFirstItem()->getProduct();
61+
$this->assertEquals('Simple Product', $productOnWishlist->getName());
62+
$this->assertEquals('Short description', $productOnWishlist->getData('short_description'));
63+
}
64+
65+
/**
66+
* @param array $attributes
67+
*/
68+
private function addAttributesToWishlistConfig($attributes)
69+
{
70+
$this->attributeConfig->merge([
71+
'wishlist_item' => $attributes
72+
]);
73+
}
74+
}

0 commit comments

Comments
 (0)