Beispiel #1
0
 /**
  * @return $this
  */
 protected function _prepareData()
 {
     $product = $this->_coreRegistry->registry('product');
     /* @var $product \Magento\Catalog\Model\Product */
     $this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect('required_options')->setPositionOrder()->addStoreFilter();
     if ($this->moduleManager->isEnabled('Magento_Checkout')) {
         $this->_addProductAttributesAndPrices($this->_itemCollection);
     }
     $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
     $this->_itemCollection->load();
     foreach ($this->_itemCollection as $product) {
         $product->setDoNotUseCategoryId(true);
     }
     return $this;
 }
Beispiel #2
0
 /**
  * @return $this
  */
 protected function _prepareData()
 {
     $product = $this->_coreRegistry->registry('product');
     /* @var $product \Magento\Catalog\Model\Product */
     $this->_itemCollection = $product->getUpSellProductCollection()->setPositionOrder()->addStoreFilter();
     if ($this->moduleManager->isEnabled('Magento_Checkout')) {
         $this->_addProductAttributesAndPrices($this->_itemCollection);
     }
     $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
     $this->_itemCollection->load();
     /**
      * Updating collection with desired items
      */
     $this->_eventManager->dispatch('catalog_product_upsell', ['product' => $product, 'collection' => $this->_itemCollection, 'limit' => null]);
     foreach ($this->_itemCollection as $product) {
         $product->setDoNotUseCategoryId(true);
     }
     return $this;
 }
 /**
  * Set product visibility filter for enabled products
  *
  * @param array $visibility
  * @return $this
  */
 public function setVisibility($visibility)
 {
     $this->addFieldToFilter('visibility', $visibility);
     return parent::setVisibility($visibility);
 }