public function testGetProductAttributes() { $expectedResult = ['attribute_one', 'attribute_two', 'attribute_three']; $this->_catalogConfig->expects($this->once())->method('getProductAttributes')->willReturn(['attribute_one', 'attribute_two']); $this->_attributeConfig->expects($this->once())->method('getAttributeNames')->with('wishlist_item')->willReturn(['attribute_three']); $this->assertEquals($expectedResult, $this->model->getProductAttributes()); }
public function testGetProductAttributes() { $this->_catalogConfig->expects($this->once())->method('getProductAttributes')->will($this->returnValue(array('attribute_one', 'attribute_two'))); $this->_attributeConfig->expects($this->once())->method('getAttributeNames')->with('wishlist_item')->will($this->returnValue(array('attribute_three'))); $expectedResult = array('attribute_one', 'attribute_two', 'attribute_three'); $this->assertEquals($expectedResult, $this->_model->getProductAttributes()); }
/** * Add products to items and item options * * @return $this */ protected function _assignProducts() { \Magento\Framework\Profiler::start('WISHLIST:' . __METHOD__, array('group' => 'WISHLIST', 'method' => __METHOD__)); $productIds = array(); $this->_productIds = array_merge($this->_productIds, array_keys($productIds)); $attributes = $this->_wishlistConfig->getProductAttributes(); /** @var \Magento\Catalog\Model\Resource\Product\Collection $productCollection */ $productCollection = $this->_productCollectionFactory->create(); if ($this->_productVisible) { $productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds()); } $productCollection->addPriceData()->addTaxPercents()->addIdFilter($this->_productIds)->addAttributeToSelect($attributes)->addOptionsToResult()->addUrlRewrite(); if ($this->_productSalable) { $productCollection = $this->_adminhtmlSales->applySalableProductTypesFilter($productCollection); } $this->_eventManager->dispatch('wishlist_item_collection_products_after_load', array('product_collection' => $productCollection)); $checkInStock = $this->_productInStock && !$this->_inventoryData->isShowOutOfStock(); foreach ($this as $item) { $product = $productCollection->getItemById($item->getProductId()); if ($product) { if ($checkInStock && !$product->isInStock()) { $this->removeItemByKey($item->getId()); } else { $product->setCustomOptions(array()); $item->setProduct($product); $item->setProductName($product->getName()); $item->setName($product->getName()); $item->setPrice($product->getPrice()); } } else { $item->isDeleted(true); } } \Magento\Framework\Profiler::stop('WISHLIST:' . __METHOD__); return $this; }