/** * Premare block data * @return $this */ protected function _prepareCollection() { $post = $this->_coreRegistry->registry('current_blog_post'); $this->_itemCollection = $this->_productCollectionFactory->create()->addAttributeToSelect('required_options')->addStoreFilter()->addAttributeToFilter('entity_id', array('in' => $post->getRelatedProductIds() ?: array(0))); if ($this->_moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($this->_itemCollection); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds()); $this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $this->_itemCollection->load(); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; }
/** * Premare block data * @return $this */ protected function _prepareCollection() { $post = $this->getPost(); $this->_itemCollection = $post->getRelatedProducts()->addAttributeToSelect('required_options'); if ($this->_moduleManager->isEnabled('Magento_Checkout')) { $this->_addProductAttributesAndPrices($this->_itemCollection); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds()); $this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $this->_itemCollection->getSelect()->order('rl.position', 'ASC'); $this->_itemCollection->load(); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; }