/** * Initialize important variables * @param Enlight_Event_EventArgs $arguments */ protected function init(Enlight_Event_EventArgs $arguments) { $this->controller = $arguments->getSubject(); $this->request = $this->controller->Request(); $this->view = $this->controller->View(); $this->helper->setRequest($this->request); }
/** * Request article recommendations for one or multiple choiceIds * * If one $choiceId is given, the result will be an array with the keys * 'results' and 'count'. For multiple $choiceId, the result is an array * with the choiceIds as the first dimension and 'results' and 'count' as * the second one. * * For generic recommendations, no special context is necessary. If you * display recommendations associated to products (i.e. on category or * basket pages) you should send along the articles detail id as 'contextItem'. * Boxalino might request you to send additional context parameters in special * cases. * * @param string|array $choiceId one choiceId of an array of multiple choiceIds * @param int $amount of products to recommend, defaults to 5 * @param array $context parameters to add to the request, i.e. array('contextItem' => 123), where 123 is the article id (not the detail id) * @param int $offset to start result from, i.e. 5 to start with the 6th item (0 based index), defaults to 0 * @return array */ public function getArticlesForChoice($choiceId, $amount = 5, $context = array(), $offset = 0) { $choiceIds = is_array($choiceId) ? $choiceId : array($choiceId); if (array_key_exists('contextItem', $context)) { $id = $context['contextItem']; unset($context['contextItem']); } else { $id = 0; } $result = $this->helper->findRecommendations($id, 'mainProduct', $choiceIds, $amount, $offset, $context); if (is_array($choiceId)) { return $result; } return current($result); }
public function __construct($event, $params) { if (empty($event)) { Shopware()->PluginLogger()->debug("event must be set, received: '{$event}', event could not be tracked"); return; } if (!array_key_exists('_a', $params)) { $params['_a'] = Shopware_Plugins_Frontend_Boxalino_P13NHelper::getAccount(); } if (!array_key_exists('_ev', $params)) { $params['_ev'] = $event; } if (!array_key_exists('_t', $params)) { $params['_t'] = round(microtime(true) * 1000); } $cems = Shopware()->Front()->Request()->getCookie('cems'); $cemv = Shopware()->Front()->Request()->getCookie('cemv'); if (!array_key_exists('_bxs', $params)) { $params['_bxs'] = empty($cems) ? self::getSessionId() : $cems; } if (!array_key_exists('_bxv', $params)) { $params['_bxv'] = empty($cemv) ? self::getSessionId() : $cemv; } if (array_key_exists('referer', $params)) { $this->referer = $params['referer']; unset($params['referer']); } else { $this->referer = array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : ''; } $this->params = $params; }
/** * @return null|Shopware_Plugins_Frontend_Boxalino_P13NHelper */ public static function instance() { if (self::$instance == null) { self::$instance = new Shopware_Plugins_Frontend_Boxalino_P13NHelper(); } return self::$instance; }
public function productStreamSliderRecommendationsAction() { $helper = Shopware_Plugins_Frontend_Boxalino_P13NHelper::instance(); $choiceId = $this->Request()->getQuery('bxChoiceId'); $count = $this->Request()->getQuery('bxCount'); $articles = $helper->findRecommendations(null, null, $choiceId, $count); $this->View()->assign('articles', $articles); }
private static function buildScript($pushes = null) { $account = Shopware_Plugins_Frontend_Boxalino_P13NHelper::getAccount(); return <<<SCRIPT <script type="text/javascript"> var _bxq = _bxq || []; _bxq.push(['setAccount', '{$account}']); _bxq.push(['trackPageView']); {$pushes} (function(){ var s = document.createElement('script'); s.async = 1; s.src = '//cdn.bx-cloud.com/frontend/rc/js/ba.min.js'; document.getElementsByTagName('head')[0].appendChild(s); })(); </script> SCRIPT; }