/** * @return $this|MageCrosssell */ protected function _prepareData($execute = true) { if ($this->bxHelperData->isCrosssellEnabled()) { $products = $this->_coreRegistry->registry('product'); $config = $this->_scopeConfig->getValue('bxRecommendations/cart', $this->scopeStore); $choiceId = isset($config['widget']) && $config['widget'] != "" ? $config['widget'] : 'complementary'; try { $entity_ids = $this->p13nHelper->getRecommendation($choiceId, $products, 'basket', $config['min'], $config['max'], $execute); } catch (\Exception $e) { $this->bxHelperData->setFallback(true); $this->_logger->critical($e); return parent::_prepareData(); } if (!$execute) { return null; } if (count($entity_ids) == 0) { $entity_ids = array(0); } $this->_itemCollection = $this->factory->create()->addFieldToFilter('entity_id', $entity_ids)->addAttributeToSelect('*'); $this->_itemCollection->load(); foreach ($this->_itemCollection as $product) { $product->setDoNotUseCategoryId(true); } return $this; } return parent::_prepareData(); }