Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,10 @@ protected function _assignProducts()
$productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
}

$attributesToSelect = [
'name',
'visibility',
'small_image',
'thumbnail',
'links_purchased_separately',
'links_title',
'price_type'
];

$productCollection->addPriceData()
->addTaxPercents()
->addIdFilter($this->_productIds)
->addAttributeToSelect($attributesToSelect)
->addAttributeToSelect($this->_wishlistConfig->getProductAttributes())
->addOptionsToResult()
->addUrlRewrite();

Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Wishlist/etc/catalog_attributes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
<group name="wishlist_item">
<attribute name="name"/>
<attribute name="small_image"/>
<attribute name="thumbnail"/>
<attribute name="links_purchased_separately"/>
<attribute name="links_title"/>
<attribute name="price_type"/>
<attribute name="visibility"/>
<attribute name="url_path"/>
<attribute name="url_key"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php


namespace Magento\Wishlist\Model\ResourceModel\Item;


use Magento\Catalog\Model\Product;
use Magento\Framework\App\ObjectManager;
use Magento\Wishlist\Model\Wishlist;
use Magento\Catalog\Model\Attribute\Config;

class CollectionTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;
/**
* @var Collection
*/
private $itemCollection;
/**
* @var Wishlist
*/
private $wishlist;
/**
* @var Config\Data
*/
private $attributeConfig;

protected function setUp()
{
$this->objectManager = ObjectManager::getInstance();
$this->wishlist = $this->objectManager->create(Wishlist::class);
$this->itemCollection = $this->objectManager->get(Collection::class);
$this->attributeConfig = $this->objectManager->get(Config\Data::class);
}
/**
* @magentoDataFixture Magento/Wishlist/_files/wishlist_shared.php
* @magentoAppIsolation enabled
* @magentoDbIsolation enabled
*/
public function testLoadedProductAttributes()
{
$this->addAttributesToWishlistConfig([
'short_description',
]);
$this->wishlist->loadByCode('fixture_unique_code');
$this->itemCollection->addWishlistFilter($this->wishlist);

/** @var Product $productOnWishlist */
$productOnWishlist = $this->itemCollection->getFirstItem()->getProduct();
$this->assertEquals('Simple Product', $productOnWishlist->getName());
$this->assertEquals('Short description', $productOnWishlist->getData('short_description'));
}

/**
* @param $attributes
*/
private function addAttributesToWishlistConfig($attributes)
{
$this->attributeConfig->merge([
'wishlist_item' => $attributes
]);
}
}