public function testClearSpecific() { $cache = \Aimeos\Controller\Frontend\Factory::setCache(true); $context = \TestHelperFrontend::getContext(); $basket1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $catalog1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); \Aimeos\Controller\Frontend\Factory::clear((string) $context, 'basket'); $basket2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $catalog2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); \Aimeos\Controller\Frontend\Factory::setCache($cache); $this->assertNotSame($basket1, $basket2); $this->assertSame($catalog1, $catalog2); }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $products = array(); $context = $this->getContext(); $config = $context->getConfig(); if (isset($view->listCurrentCatItem)) { /** client/html/catalog/lists/promo/size * The maximum number of products that should be shown in the promotion section * * Each product list can render a list of promoted products on * top if there are any products associated to that category whose * list type is "promotion". This option limits the maximum number * of products that are displayed. It takes only effect if more * promotional products are added to this category than the set * value. * * @param integer Number of promotion products * @since 2014.03 * @category User * @category Developer */ $size = $config->get('client/html/catalog/lists/promo/size', 6); $domains = $config->get('client/html/catalog/lists/domains', array('media', 'price', 'text')); $total = null; $catId = $view->listCurrentCatItem->getId(); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $filter = $controller->createIndexFilterCategory($catId, 'relevance', '+', 0, $size, 'promotion'); $products = $controller->getIndexItems($filter, $domains, $total); } if (!empty($products) && $config->get('client/html/catalog/lists/stock/enable', true) === true) { $stockTarget = $config->get('client/html/catalog/stock/url/target'); $stockController = $config->get('client/html/catalog/stock/url/controller', 'catalog'); $stockAction = $config->get('client/html/catalog/stock/url/action', 'stock'); $stockConfig = $config->get('client/html/catalog/stock/url/config', array()); $productIds = array_keys($products); sort($productIds); $params = array('s_prodid' => implode(' ', $productIds)); $view->promoStockUrl = $view->url($stockTarget, $stockController, $stockAction, $params, array(), $stockConfig); } $this->addMetaItem($products, 'product', $this->expire, $this->tags); $this->addMetaList(array_keys($products), 'product', $this->expire); $view->promoItems = $products; $this->cache = $view; } $expire = $this->expires($this->expire, $expire); $tags = array_merge($tags, $this->tags); return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); try { $langid = $basketCntl->get()->getAddress('payment')->getLanguageId(); } catch (\Exception $e) { $langid = $view->param('ca_billing/order.base.address.languageid', $context->getLocale()->getLanguageId()); } $view->billingLanguage = $langid; /** client/html/checkout/standard/address/billing/hidden * List of billing address input fields that are optional and should be hidden * * You can configure the list of billing address fields that * are hidden when a customer enters his new billing address. * Available field keys are: * * order.base.address.company * * order.base.address.vatid * * order.base.address.salutation * * order.base.address.firstname * * order.base.address.lastname * * order.base.address.address1 * * order.base.address.address2 * * order.base.address.address3 * * order.base.address.postal * * order.base.address.city * * order.base.address.state * * order.base.address.languageid * * order.base.address.countryid * * order.base.address.telephone * * order.base.address.telefax * * order.base.address.email * * order.base.address.website * * Caution: Only hide fields that don't require any input * * Until 2015-02, the configuration option was available as * "client/html/common/address/billing/hidden" starting from 2014-03. * * @param array List of field keys * @since 2015.02 * @category User * @category Developer * @see client/html/checkout/standard/address/billing/disable-new * @see client/html/checkout/standard/address/billing/salutations * @see client/html/checkout/standard/address/billing/mandatory * @see client/html/checkout/standard/address/billing/optional * @see client/html/checkout/standard/address/countries */ $hidden = $view->config('client/html/checkout/standard/address/billing/hidden', array()); if (count($view->get('addressLanguages', array())) === 1) { $hidden[] = 'order.base.address.languageid'; } $salutations = array('company', 'mr', 'mrs'); /** client/html/checkout/standard/address/billing/salutations * List of salutions the customer can select from for the billing address * * The following salutations are available: * * empty string for "unknown" * * company * * mr * * mrs * * miss * * You can modify the list of salutation codes and remove the ones * which shouldn't be used. Adding new salutations is a little bit * more difficult because you have to adapt a few areas in the source * code. * * Until 2015-02, the configuration option was available as * "client/html/common/address/billing/salutations" starting from 2014-03. * * @param array List of available salutation codes * @since 2015.02 * @category User * @category Developer * @see client/html/checkout/standard/address/billing/disable-new * @see client/html/checkout/standard/address/billing/mandatory * @see client/html/checkout/standard/address/billing/optional * @see client/html/checkout/standard/address/billing/hidden * @see client/html/checkout/standard/address/countries */ $view->billingSalutations = $view->config('client/html/checkout/standard/address/billing/salutations', $salutations); $view->billingMandatory = $view->config('client/html/checkout/standard/address/billing/mandatory', $this->mandatory); $view->billingOptional = $view->config('client/html/checkout/standard/address/billing/optional', $this->optional); $view->billingHidden = $hidden; $this->cache = $view; } return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $config = $context->getConfig(); $attrIds = $attributeMap = $subAttrDeps = array(); if (isset($view->detailProductItem)) { $attrIds = array_keys($view->detailProductItem->getRefItems('attribute', null, 'default')); $attrIds += array_keys($view->detailProductItem->getRefItems('attribute', null, 'variant')); } $products = $view->detailProductItem->getRefItems('product', 'default', 'default'); /** client/html/catalog/detail/additional/attribute/domains * A list of domain names whose items should be available in the additional attribute part of the catalog detail view templates * * The templates rendering additional attribute related data usually add * the images and texts associated to each item. If you want to * display additional content like the attributes, you can configure * your own list of domains (attribute, media, price, product, text, * etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the * configuration, the more time is required for fetching the content! * * @param array List of domain names * @since 2015.09 * @category Developer * @see client/html/catalog/detail/basket/selection/domains-attributes */ $domains = $config->get('client/html/catalog/detail/basket/selection/domains', array('attribute')); // find regular attributes from sub-products $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $products = $controller->getProductItems(array_keys($products), $domains); foreach ($products as $subProdId => $subProduct) { $subItems = $subProduct->getRefItems('attribute', null, 'default'); $subItems += $subProduct->getRefItems('attribute', null, 'variant'); foreach ($subItems as $attrId => $attrItem) { $subAttrDeps[$attrId][] = $subProdId; $attrIds[] = $attrId; } } $this->addMetaItem($products, 'product', $this->expire, $this->tags); $this->addMetaList(array_keys($products), 'product', $this->expire); $attrManager = $controller->createManager('attribute'); $search = $attrManager->createSearch(true); $expr = array($search->compare('==', 'attribute.id', $attrIds), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); /** client/html/catalog/detail/basket/selection/domains-attributes * A list of domain names whose items should be available for the attributes in the * additional attribute part of the catalog detail view templates * * The templates rendering additional attribute related data usually add * the images and texts associated to each item. If you want to * display additional content like the attributes, you can configure * your own list of domains (attribute, media, price, product, text, * etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the * configuration, the more time is required for fetching the content! * * @param array List of domain names * @since 2015.09 * @category Developer * @see client/html/catalog/detail/basket/selection/domains */ $domains = $config->get('client/html/catalog/detail/basket/selection/domains-attributes', array('text', 'media')); $attributes = $attrManager->searchItems($search, $domains); foreach ($attributes as $id => $item) { $attributeMap[$item->getType()][$id] = $item; } $this->addMetaItem($attributes, 'attribute', $this->expire, $this->tags); $this->addMetaList(array_keys($attributes), 'attribute', $this->expire); $view->attributeMap = $attributeMap; $view->subAttributeDependencies = $subAttrDeps; $this->cache = $view; } $expire = $this->expires($this->expire, $expire); $tags = array_merge($tags, $this->tags); return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $view->standardBasket = $basketCntl->get(); /** client/html/checkout/standard/url/step-active * Name of the checkout process step to jump to if no previous step requires attention * * The checkout process consists of several steps which are usually * displayed one by another to the customer. If the data of a step * is already available, then that step is skipped. The active step * is the one that is displayed if all other steps are skipped. * * If one of the previous steps misses some data the customer has * to enter, then this step is displayed first. After providing * the missing data, the whole series of steps are tested again * and if no other step requests attention, the configured active * step will be displayed. * * The order of the steps is determined by the order of sub-parts * that are configured for the checkout client. * * @param string Name of the confirm standard HTML client * @since 2014.07 * @category Developer * @category User * @see client/html/checkout/standard/standard/subparts */ $default = $view->config('client/html/checkout/standard/url/step-active', 'summary'); /** client/html/checkout/standard/onepage * Shows all named checkout subparts at once for a one page checkout * * Normally, the checkout process is divided into several steps for entering * addresses, select delivery and payment options as well as showing the * summary page. This enables dependencies between two steps like showing * delivery options based on the address entered by the customer. Furthermore, * this is good way to limit the amount of information displayed which is * preferred by mobile users. * * Contrary to that, a one page checkout displays all information on only * one page and customers get an immediate overview of which information * they have to enter and what options they can select from. This is an * advantage if only a very limited amount of information must be entered * or if there are almost no options to choose from and no dependencies * between exist. * * Using this config options, shop developers are able to define which * checkout subparts are combined to a one page view. Simply add the names * of all checkout subparts to the list. Available checkout subparts for * a one page checkout are: * * address * * delivery * * payment * * summary * * @param array List of checkout subparts name * @since 2015.05 * @category Developer */ $onepage = $view->config('client/html/checkout/standard/onepage', array()); $onestep = !empty($onepage) ? array_shift($onepage) : $default; // keep the first one page step $steps = (array) $context->getConfig()->get($this->subPartPath, $this->subPartNames); $steps = array_diff($steps, $onepage); // remove all remaining steps in $onepage // use first step if default step isn't available $default = !in_array($default, $steps) ? reset($steps) : $default; $current = $view->param('c_step', $default); // use $onestep if the current step isn't available due to one page layout if (!in_array($current, $steps)) { $current = $onestep; } // use $onestep if the active step isn't available due to one page layout if (isset($view->standardStepActive) && in_array($view->standardStepActive, $onepage)) { $view->standardStepActive = $onestep; } $cpos = array_search($current, $steps); if (!isset($view->standardStepActive) || ($apos = array_search($view->standardStepActive, $steps)) !== false && $cpos !== false && $cpos < $apos) { $view->standardStepActive = $current; } $view->standardSteps = $steps; $this->cache = $this->addNavigationUrls($view, $steps, $view->standardStepActive); } return $this->cache; }
/** * Processes the input, e.g. store given values. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $context = $this->getContext(); switch ($view->param('b_action')) { case 'coupon-delete': if (($coupon = $view->param('b_coupon')) != '') { $this->clearCached(); $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $cntl->deleteCoupon($coupon); } break; default: if (($coupon = $view->param('b_coupon')) != '') { $this->clearCached(); $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); /** client/html/basket/standard/coupon/allowed * Number of coupon codes a customer is allowed to enter * * This configuration option enables shop owners to limit the number of coupon * codes that can be added by a customer to his current basket. By default, only * one coupon code is allowed per order. * * Coupon codes are valid until a payed order is placed by the customer. The * "count" of the codes is decreased afterwards. If codes are not personalized * the codes can be reused in the next order until their "count" reaches zero. * * @param integer Positive number of coupon codes including zero * @since 2014.05 * @category User * @category Developer */ $allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1); if ($allowed <= count($cntl->get()->getCoupons())) { throw new \Aimeos\Client\Html\Exception(sprintf('Number of coupon codes exceeds the limit')); } $cntl->addCoupon($coupon); } break; } parent::process(); }
public static function bootstrap() { self::getAimeos(); \Aimeos\MShop\Factory::setCache(false); \Aimeos\Controller\Frontend\Factory::setCache(false); }
/** * Processes the input, e.g. store given order. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $errors = $view->get('standardErrorList', array()); if (!in_array($view->param('c_step'), array('order', 'process')) || !empty($errors)) { return; } $context = $this->getContext(); $session = $context->getSession(); $orderid = $session->get('aimeos/orderid'); $config = array('absoluteUri' => true, 'namespace' => false); try { $orderItem = \Aimeos\MShop\Factory::createManager($context, 'order')->getItem($orderid); if (($code = $this->getOrderServiceCode($orderItem->getBaseId())) !== null) { $serviceItem = $this->getServiceItem($code); $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); $provider = $serviceManager->getProvider($serviceItem); $args = array('code' => $serviceItem->getCode(), 'orderid' => $orderid); $urls = array('payment.url-self' => $this->getUrlSelf($view, $args + array('c_step' => 'process'), array()), 'payment.url-success' => $this->getUrlConfirm($view, $args, $config), 'payment.url-update' => $this->getUrlUpdate($view, $args, $config), 'client.ipaddress' => $view->request()->getClientAddress()); $provider->injectGlobalConfigBE($urls); $params = $view->param(); try { $basket = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket')->get(); $attrs = $basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT)->getAttributes(); foreach ($attrs as $item) { $params[$item->getCode()] = $item->getValue(); } } catch (\Exception $e) { } // nothing available if (($form = $provider->process($orderItem, $params)) === null) { $msg = sprintf('Invalid process response from service provider with code "%1$s"', $serviceItem->getCode()); throw new \Aimeos\Client\Html\Exception($msg); } $view->standardUrlNext = $form->getUrl(); $view->standardMethod = $form->getMethod(); $view->standardProcessParams = $form->getValues(); $view->standardUrlExternal = $form->getExternal(); } else { $view->standardUrlNext = $this->getUrlConfirm($view, array(), array()); $view->standardMethod = 'GET'; } parent::process(); } catch (\Aimeos\Client\Html\Exception $e) { $error = array($context->getI18n()->dt('client', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Aimeos\Controller\Frontend\Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Aimeos\MShop\Exception $e) { $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $view->standardBasket = $basketCntl->get(); $bTarget = $view->config('client/html/basket/standard/url/target'); $bCntl = $view->config('client/html/basket/standard/url/controller', 'basket'); $bAction = $view->config('client/html/basket/standard/url/action', 'index'); $bConfig = $view->config('client/html/basket/standard/url/config', array()); /** client/html/checkout/standard/url/target * Destination of the URL where the controller specified in the URL is known * * The destination can be a page ID like in a content management system or the * module of a software development framework. This "target" must contain or know * the controller that should be called by the generated URL. * * @param string Destination of the URL * @since 2014.03 * @category Developer * @see client/html/checkout/standard/url/controller * @see client/html/checkout/standard/url/action * @see client/html/checkout/standard/url/config */ $cTarget = $view->config('client/html/checkout/standard/url/target'); /** client/html/checkout/standard/url/controller * Name of the controller whose action should be called * * In Model-View-Controller (MVC) applications, the controller contains the methods * that create parts of the output displayed in the generated HTML page. Controller * names are usually alpha-numeric. * * @param string Name of the controller * @since 2014.03 * @category Developer * @see client/html/checkout/standard/url/target * @see client/html/checkout/standard/url/action * @see client/html/checkout/standard/url/config */ $cCntl = $view->config('client/html/checkout/standard/url/controller', 'checkout'); /** client/html/checkout/standard/url/action * Name of the action that should create the output * * In Model-View-Controller (MVC) applications, actions are the methods of a * controller that create parts of the output displayed in the generated HTML page. * Action names are usually alpha-numeric. * * @param string Name of the action * @since 2014.03 * @category Developer * @see client/html/checkout/standard/url/target * @see client/html/checkout/standard/url/controller * @see client/html/checkout/standard/url/config */ $cAction = $view->config('client/html/checkout/standard/url/action', 'index'); /** client/html/checkout/standard/url/config * Associative list of configuration options used for generating the URL * * You can specify additional options as key/value pairs used when generating * the URLs, like * * client/html/<clientname>/url/config = array( 'absoluteUri' => true ) * * The available key/value pairs depend on the application that embeds the e-commerce * framework. This is because the infrastructure of the application is used for * generating the URLs. The full list of available config options is referenced * in the "see also" section of this page. * * @param string Associative list of configuration options * @since 2014.03 * @category Developer * @see client/html/checkout/standard/url/target * @see client/html/checkout/standard/url/controller * @see client/html/checkout/standard/url/action * @see client/html/url/config */ $cConfig = $view->config('client/html/checkout/standard/url/config', array()); /** client/html/checkout/standard/url/step-active * Name of the checkout process step to jump to if no previous step requires attention * * The checkout process consists of several steps which are usually * displayed one by another to the customer. If the data of a step * is already available, then that step is skipped. The active step * is the one that is displayed if all other steps are skipped. * * If one of the previous steps misses some data the customer has * to enter, then this step is displayed first. After providing * the missing data, the whole series of steps are tested again * and if no other step requests attention, the configured active * step will be displayed. * * The order of the steps is determined by the order of sub-parts * that are configured for the checkout client. * * @param string Name of the confirm standard HTML client * @since 2014.07 * @category Developer * @category User * @see client/html/checkout/standard/standard/subparts */ $default = $view->config('client/html/checkout/standard/url/step-active', 'summary'); /** client/html/checkout/standard/onepage * Shows all named checkout subparts at once for a one page checkout * * Normally, the checkout process is divided into several steps for entering * addresses, select delivery and payment options as well as showing the * summary page. This enables dependencies between two steps like showing * delivery options based on the address entered by the customer. Furthermore, * this is good way to limit the amount of information displayed which is * preferred by mobile users. * * Contrary to that, a one page checkout displays all information on only * one page and customers get an immediate overview of which information * they have to enter and what options they can select from. This is an * advantage if only a very limited amount of information must be entered * or if there are almost no options to choose from and no dependencies * between exist. * * Using this config options, shop developers are able to define which * checkout subparts are combined to a one page view. Simply add the names * of all checkout subparts to the list. Available checkout subparts for * a one page checkout are: * * address * * delivery * * payment * * summary * * @param array List of checkout subparts name * @since 2015.05 * @category Developer */ $onepage = $view->config('client/html/checkout/standard/onepage', array()); $onestep = array_shift($onepage); // keep the first one page step $steps = (array) $context->getConfig()->get($this->subPartPath, $this->subPartNames); $steps = array_diff($steps, $onepage); // remove all remaining steps in $onepage // use first step if default step isn't available $default = !in_array($default, $steps) ? reset($steps) : $default; $current = $view->param('c_step', $default); // use $onestep if current step isn't available due to one page layout $current = !in_array($current, $steps) ? $onestep : $current; $cpos = $cpos = array_search($current, $steps); if (!isset($view->standardStepActive) || ($apos = array_search($view->standardStepActive, $steps)) !== false && $cpos !== false && $cpos < $apos) { $view->standardStepActive = $current; } $activeStep = $view->standardStepActive; $view->standardSteps = $steps; $step = null; do { $lastStep = $step; } while (($step = array_shift($steps)) !== null && $step !== $activeStep); if ($lastStep !== null) { $param = array('c_step' => $lastStep); $view->standardUrlBack = $view->url($cTarget, $cCntl, $cAction, $param, array(), $cConfig); } else { $view->standardUrlBack = $view->url($bTarget, $bCntl, $bAction, array(), array(), $bConfig); } if (!isset($view->standardUrlNext) && ($nextStep = array_shift($steps)) !== null) { $param = array('c_step' => $nextStep); $view->standardUrlNext = $view->url($cTarget, $cCntl, $cAction, $param, array(), $cConfig); } // don't overwrite $view->standardUrlNext so order step URL is used $this->cache = $view; } return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $input = $view->param('f_search'); $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); $filter = $controller->createTextFilter($input); $items = $controller->getTextList($filter); $suggestTextItems = array(); foreach ($items as $id => $name) { $suggestTextItems[] = array("id" => $id, "name" => $name); } $view->suggestTextItems = $suggestTextItems; $this->cache = $view; } return $this->cache; }
/** * Processes the input, e.g. store given order. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); try { // only start if there's something to do if (($option = $view->param('cs_order', null)) === null || $view->get('standardStepActive') !== null) { return; } $context = $this->getContext(); $orderBaseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); $basket = $orderBaseManager->getSession(); $basket->setCustomerId($context->getUserId()); $basket->finish(); $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'order'); $orderItem = $cntl->store($basket); $cntl->block($orderItem); $context->getSession()->set('aimeos/orderid', $orderItem->getId()); $view->orderItem = $orderItem; $view->orderBasket = $basket; parent::process(); // save again after sub-clients modified it's state \Aimeos\MShop\Factory::createManager($context, 'order')->saveItem($orderItem); } catch (\Exception $e) { $view->standardStepActive = 'order'; throw $e; } }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $attrMap = array(); $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); /** client/html/catalog/filter/attribute/types * List of attribute types that should be displayed in this order in the catalog filter * * The attribute section in the catalog filter component can display * all attributes a visitor can use to reduce the listed products * to those that contains one or more attributes. By default, all * available attributes will be displayed and ordered by their * attribute type. * * With this setting, you can limit the attribute types to only thoses * whose names are part of the setting value. Furthermore, a particular * order for the attribute types can be enforced that is different * from the standard order. * * @param array List of attribute type codes * @since 2015.05 * @category User * @category Developer * @see client/html/catalog/filter/attribute/domains */ $attrTypes = $view->config('client/html/catalog/filter/attribute/types', array()); $manager = $controller->createManager('attribute'); $search = $manager->createSearch(true); $expr = array(); if (!empty($attrTypes)) { $expr[] = $search->compare('==', 'attribute.type.code', $attrTypes); } $expr[] = $search->compare('==', 'attribute.domain', 'product'); $expr[] = $search->getConditions(); $sort = array($search->sort('+', 'attribute.position')); $search->setConditions($search->combine('&&', $expr)); $search->setSortations($sort); /** client/html/catalog/filter/attribute/domains * List of domain names whose items should be fetched with the filter attributes * * The templates rendering the attributes in the catalog filter usually * add the images and texts associated to each item. If you want to * display additional content, you can configure your own list of * domains (attribute, media, price, product, text, etc. are domains) * whose items are fetched from the storage. Please keep in mind that * the more domains you add to the configuration, the more time is * required for fetching the content! * * @param array List of domain item names * @since 2015.05 * @category Developer * @see client/html/catalog/filter/attribute/types */ $domains = $view->config('client/html/catalog/filter/attribute/domains', array('text', 'media')); $attributes = $manager->searchItems($search, $domains); foreach ($attributes as $id => $item) { $attrMap[$item->getType()][$id] = $item; } if (!empty($attrTypes)) { $sortedMap = array(); foreach ($attrTypes as $type) { if (isset($attrMap[$type])) { $sortedMap[$type] = $attrMap[$type]; } } $attrMap = $sortedMap; } else { ksort($attrMap); } $this->addMetaItem($attributes, 'attribute', $this->expire, $this->tags); $this->addMetaList(array_keys($attributes), 'attribute', $this->expire); // Delete cache when attributes are added or deleted even in "tag-all" mode $this->tags[] = 'attribute'; $view->attributeMap = $attrMap; $this->cache = $view; } $expire = $this->expires($this->expire, $expire); $tags = array_merge($tags, $this->tags); return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $config = $context->getConfig(); $products = $this->getProductList($view); $text = (string) $view->param('f_search'); $catid = (string) $view->param('f_catid'); if ($catid == '') { $catid = $config->get('client/html/catalog/lists/catid-default', ''); } if ($text === '' && $catid !== '') { $domains = $config->get('client/html/catalog/domains', array('media', 'text')); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $listCatPath = $controller->getCatalogPath($catid, $domains); if (($categoryItem = end($listCatPath)) !== false) { $view->listCurrentCatItem = $categoryItem; } $view->listCatPath = $listCatPath; $this->addMetaItem($listCatPath, 'catalog', $this->expire, $this->tags); $this->addMetaList(array_keys($listCatPath), 'catalog', $this->expire); } /** client/html/catalog/lists/stock/enable * Enables or disables displaying product stock levels in product list views * * This configuration option allows shop owners to display product * stock levels for each product in list views or to disable * fetching product stock information. * * The stock information is fetched via AJAX and inserted via Javascript. * This allows to cache product items by leaving out such highly * dynamic content like stock levels which changes with each order. * * @param boolean Value of "1" to display stock levels, "0" to disable displaying them * @since 2014.03 * @category User * @category Developer * @see client/html/catalog/detail/stock/enable * @see client/html/catalog/stock/url/target * @see client/html/catalog/stock/url/controller * @see client/html/catalog/stock/url/action * @see client/html/catalog/stock/url/config */ if (!empty($products) && $config->get('client/html/catalog/lists/stock/enable', true) === true) { $view->listStockUrl = $this->getStockUrl($view, array_keys($products)); } $this->addMetaItem($products, 'product', $this->expire, $this->tags); $this->addMetaList(array_keys($products), 'product', $this->expire); // Delete cache when products are added or deleted even when in "tag-all" mode $this->tags[] = 'product'; $view->listParams = $this->getClientParams($view->param()); $view->listPageCurr = $this->getProductListPage($view); $view->listPageSize = $this->getProductListSize($view); $view->listProductTotal = $this->getProductListTotal($view); $view->listProductSort = $view->param('f_sort', 'relevance'); $view->listProductItems = $products; $this->cache = $view; } $expire = $this->expires($this->expire, $expire); $tags = array_merge($tags, $this->tags); return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $codes = array(); $context = $this->getContext(); $input = $view->param('f_search'); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $filter = $controller->createTextFilter($input, null, '+', 0, 25, 'default', 'name'); $texts = $controller->getTextList($filter); /** client/html/catalog/suggest/usecode * Enables product suggestions based on using the product code * * The suggested entries for the full text search in the catalog filter component * are based on the product names by default. By setting this option to true or 1, * you can add suggestions based on the product codes as well. * * @param boolean True to search for product codes too, false for product names only * @since 2016.09 * @category Developer */ if ($context->getConfig()->get('client/html/catalog/suggest/usecode', false)) { $filter = $controller->createTextFilter($input, null, '+', 0, 25, 'default', 'code'); $codes = $controller->getTextList($filter); } /** client/html/catalog/suggest/domains * List of domain items that should be fetched along with the products * * The suggsted entries for the full text search in the catalog filter component * usually consist of the names of the matched products. By default, only the * product item including the localized name is available. You can add more domains * like e.g. "media" to get the images of the product as well. * * '''Note:''' The more domains you will add, the slower the autocomplete requests * will be! Keep it to an absolute minium for user friendly response times. * * @param array List of domain names * @since 2016.08 * @category Developer * @see client/html/catalog/suggest/standard/template-body */ $domains = $context->getConfig()->get('client/html/catalog/suggest/domains', array()); $manager = $controller->createManager('product'); $search = $manager->createSearch(true); $expr = array($search->compare('==', 'product.id', array_merge(array_keys($texts), array_keys($codes))), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $result = $manager->searchItems($search, $domains); // shortcut to avoid having to fetch the text items to get the the localized name foreach ($result as $id => $item) { if (isset($texts[$id])) { $item->setLabel($texts[$id]); } } $view->suggestItems = $result; $this->cache = $view; } return $this->cache; }
/** * Returns the product items for the given IDs. * * @param string[] $ids List of product IDs * @return \Aimeos\MShop\Product\Item\Iface[] List of product items */ protected function getProductItems(array $ids) { $context = $this->getContext(); $config = $context->getConfig(); /** client/html/basket/related/bought/standard/domains * The list of domain names whose items should be available in the template for the products * * The templates rendering product details usually add the images, * prices and texts, etc. associated to the product * item. If you want to display additional or less content, you can * configure your own list of domains (attribute, media, price, product, * text, etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the configuration, * the more time is required for fetching the content! * * @param array List of domain names * @since 2014.09 * @category Developer */ $domains = array('text', 'price', 'media'); $domains = $config->get('client/html/basket/related/bought/standard/domains', $domains); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); return $controller->getProductItems($ids, $domains); }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $config = $context->getConfig(); if ($config->get('client/html/catalog/lists/basket-add', false)) { $products = $view->get('listProductItems', array()); $domains = array('media', 'price', 'text', 'attribute', 'product'); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $productIds = $this->getProductIds($products); $productManager = $controller->createManager('product'); $productItems = $this->getDomainItems($productManager, 'product.id', $productIds, $domains); $this->addMetaItems($productItems, $this->expire, $this->tags); $attrIds = $this->getAttributeIds($productItems); $attributeManager = $controller->createManager('attribute'); $attributeItems = $this->getDomainItems($attributeManager, 'attribute.id', $attrIds, $domains); $this->addMetaItems($attributeItems, $this->expire, $this->tags); $mediaIds = $this->getMediaIds($productItems); $mediaManager = $controller->createManager('media'); $mediaItems = $this->getDomainItems($mediaManager, 'media.id', $mediaIds, $domains); $this->addMetaItems($mediaItems, $this->expire, $this->tags); if (!empty($productIds) && $config->get('client/html/catalog/lists/stock/enable', true) === true) { $view->itemsStockUrl = $this->getStockUrl($view, $productIds); } $view->itemsAttributeItems = $attributeItems; $view->itemsProductItems = $productItems; $view->itemsMediaItems = $mediaItems; } $view->itemPosition = ($this->getProductListPage($view) - 1) * $this->getProductListSize($view); $this->cache = $view; } return $this->cache; }
/** * Processes the input, e.g. store given values. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); try { parent::process(); $context = $this->getContext(); if (($param = $view->param('ca_extra')) !== null) { $context->getSession()->set('client/html/checkout/standard/address/extra', (array) $param); } $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); // Test if addresses are available $addresses = $basketCntl->get()->getAddresses(); if (!isset($view->standardStepActive) && count($addresses) === 0) { $view->standardStepActive = 'address'; return false; } } catch (\Exception $e) { $this->getView()->standardStepActive = 'address'; throw $e; } }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $config = $context->getConfig(); /** client/html/catalog/count/attribute/aggregate * Enables or disables generating product counts for the attribute catalog filter * * This configuration option allows shop owners to enable or disable product counts * for the attribute section of the catalog filter HTML client. * * @param boolean Disabled if "0", enabled if "1" * @since 2014.03 * @see client/html/catalog/count/limit * @category Developer * @category User */ if ($config->get('client/html/catalog/count/attribute/aggregate', true) == true) { /** client/html/catalog/count/limit * Limits the number of records that are used for product counts in the catalog filter * * The product counts in the catalog filter are generated by searching for all * products that match the criteria and then counting the number of products * that are available for each attribute or category. * * As counting huge amount of records (several 10 000 records) takes a long time, * the limit can cut down response times so the counts are available more quickly * in the front-end and the server load is reduced. * * Using a low limit can lead to incorrect numbers if the amount of found products * is very high. Approximate product counts are normally not a problem but it can * lead to the situation that visitors see that no products are available for * an attribute or in a category despite the fact that there would be at least * one. * * @param integer Number of records * @since 2014.03 * @see client/html/catalog/count/attribute/aggregate * @category Developer * @category User */ $filter = $this->getProductListFilter($view); $filter->setSlice(0, $config->get('client/html/catalog/count/limit', 10000)); $filter->setSortations(array()); // it's not necessary and slows down the query $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $view->attributeCountList = $controller->aggregateIndex($filter, 'index.attribute.id'); } $this->cache = $view; } return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { if (isset($view->detailProductItem) && $view->detailProductItem->getType() === 'bundle') { $context = $this->getContext(); $config = $context->getConfig(); $domains = array('text', 'price', 'media'); $products = $view->detailProductItem->getRefItems('product', null, 'default'); /** client/html/catalog/detail/domains * A list of domain names whose items should be available in the catalog view templates * * @see client/html/catalog/detail/domains */ $domains = $config->get('client/html/catalog/detail/domains', $domains); /** client/html/catalog/detail/bundle/domains * A list of domain names whose items should be available in the bundle part of the catalog detail view templates * * The templates rendering bundle related data usually add * the images and texts associated to each item. If you want to * display additional content like the attributes, you can configure * your own list of domains (attribute, media, price, product, text, * etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the * configuration, the more time is required for fetching the content! * * This configuration option can be overwritten by the * "client/html/catalog/detail/domains" configuration option that * allows to configure the domain names of the items fetched * specifically for all types of product listings. * * @param array List of domain names * @since 2015.09 * @category Developer * @see client/html/catalog/detail/domains */ $domains = $config->get('client/html/catalog/detail/bundle/domains', $domains); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $view->bundleItems = $controller->getProductItems(array_keys($products), $domains); $view->bundlePosItems = $products; $this->addMetaItem($view->bundleItems, 'product', $this->expire, $this->tags); $this->addMetaList(array_keys($view->bundleItems), 'product', $this->expire); } $this->cache = $view; } $expire = $this->expires($this->expire, $expire); $tags = array_merge($tags, $this->tags); return $this->cache; }
/** * Processes the input, e.g. store given values. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); if ($view->param('cs_order', null) === null) { return; } try { $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket'); $controller->get()->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL); parent::process(); } catch (\Exception $e) { $view->standardStepActive = 'summary'; throw $e; } }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $expire = null; $tags = $items = array(); $context = $this->getContext(); $config = $context->getConfig(); $session = $context->getSession(); $default = array('media', 'price', 'text'); $domains = $config->get('client/html/catalog/domains', $default); /** client/html/catalog/session/pinned/domains * A list of domain names whose items should be available in the pinned view template for the product * * The templates rendering product details usually add the images, * prices and texts, etc. associated to the product * item. If you want to display additional or less content, you can * configure your own list of domains (attribute, media, price, product, * text, etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the configuration, * the more time is required for fetching the content! * * From 2014.09 to 2015.03, this setting was available as * client/html/catalog/detail/pinned/domains * * @param array List of domain names * @since 2015.04 * @category Developer * @see client/html/catalog/domains * @see client/html/catalog/lists/domains * @see client/html/catalog/detail/domains */ $domains = $config->get('client/html/catalog/session/pinned/domains', $domains); $pinned = $session->get('aimeos/catalog/session/pinned/list', array()); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $result = $controller->getProductItems($pinned, $domains); foreach (array_reverse($pinned) as $id) { if (isset($result[$id])) { $items[$id] = $result[$id]; } } $view->pinnedProductItems = $items; $view->pinnedParams = $this->getClientParams($view->param()); $this->cache = $view; } return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $config = $context->getConfig(); /** client/html/catalog/count/tree/aggregate * Enables or disables generating product counts for the category catalog filter * * This configuration option allows shop owners to enable or disable product counts * for the tree section of the catalog filter HTML client. * * @param boolean Disabled if "0", enabled if "1" * @since 2014.03 * @see client/html/catalog/count/limit */ if ($config->get('client/html/catalog/count/tree/aggregate', true) == true) { /** client/html/catalog/count/limit * @see client/html/catalog/count/tree/aggregate */ $filter = $this->getProductListFilter($view, false); $filter->setSlice(0, $config->get('client/html/catalog/count/limit', 10000)); $filter->setSortations(array()); // it's not necessary and slows down the query $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $view->treeCountList = $controller->aggregateIndex($filter, 'index.catalog.id'); } $this->cache = $view; } return $this->cache; }
/** * Returns the product item for the given ID including the domain items * * @param string $prodid Unique product ID * @param array List of domain items that should be fetched too * @throws \Aimeos\Client\Html\Exception If no product item was found * @return \Aimeos\MShop\Product\Item\Iface Product item object */ protected function getProductItem($prodid, array $domains) { $context = $this->getContext(); $config = $context->getConfig(); if ($prodid == '') { /** client/html/catalog/detail/prodid-default * The default product ID used if none is given as parameter * * To display a product detail view or a part of it for a specific * product, you can configure its ID using this setting. This is * most useful in a CMS where the product ID can be configured * separately for each content node. * * @param string Product ID * @since 2016.01 * @category User * @category Developer * @see client/html/catalog/lists/catid-default */ $prodid = $config->get('client/html/catalog/detail/prodid-default', ''); } /** client/html/catalog/domains * A list of domain names whose items should be available in the catalog view templates * * @see client/html/catalog/detail/domains */ $domains = $config->get('client/html/catalog/domains', $domains); /** client/html/catalog/detail/domains * A list of domain names whose items should be available in the product detail view template * * The templates rendering product details usually add the images, * prices, texts, attributes, products, etc. associated to the product * item. If you want to display additional or less content, you can * configure your own list of domains (attribute, media, price, product, * text, etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the configuration, * the more time is required for fetching the content! * * Since version 2014.05 this configuration option overwrites the * "client/html/catalog/domains" option that allows to configure the * domain names of the items fetched for all catalog related data. * * @param array List of domain names * @since 2014.03 * @category Developer * @see client/html/catalog/domains * @see client/html/catalog/lists/domains */ $domains = $config->get('client/html/catalog/detail/domains', $domains); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $items = $controller->getProductItems(array($prodid), $domains); if (($item = reset($items)) === false) { throw new \Aimeos\Client\Html\Exception(sprintf('No product with ID "%1$s" found', $prodid)); } return $item; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $total = 0; $productIds = array(); $context = $this->getContext(); $typeItem = $this->getTypeItem('customer/lists/type', 'product', 'favorite'); $size = $this->getProductListSize($view); $current = $this->getProductListPage($view); $last = $total != 0 ? ceil($total / $size) : 1; $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.lists.parentid', $context->getUserId()), $search->compare('==', 'customer.lists.typeid', $typeItem->getId()), $search->compare('==', 'customer.lists.domain', 'product')); $search->setConditions($search->combine('&&', $expr)); $search->setSortations(array($search->sort('-', 'customer.lists.position'))); $search->setSlice(($current - 1) * $size, $size); $view->favoriteListItems = $manager->searchItems($search, array(), $total); /** client/html/account/favorite/domains * A list of domain names whose items should be available in the account favorite view template * * The templates rendering product details usually add the images, * prices and texts associated to the product item. If you want to * display additional or less content, you can configure your own * list of domains (attribute, media, price, product, text, etc. are * domains) whose items are fetched from the storage. Please keep * in mind that the more domains you add to the configuration, the * more time is required for fetching the content! * * @param array List of domain names * @since 2014.09 * @category Developer * @see client/html/catalog/domains */ $default = array('text', 'price', 'media'); $domains = $context->getConfig()->get('client/html/account/favorite/domains', $default); foreach ($view->favoriteListItems as $listItem) { $productIds[] = $listItem->getRefId(); } $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $view->favoriteProductItems = $controller->getProductItems($productIds, $domains); $view->favoritePageFirst = 1; $view->favoritePagePrev = $current > 1 ? $current - 1 : 1; $view->favoritePageNext = $current < $last ? $current + 1 : $last; $view->favoritePageLast = $last; $view->favoritePageCurr = $current; $this->cache = $view; } return $this->cache; }
/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { unset($this->object); \Aimeos\Controller\Frontend\Factory::clear(); \Aimeos\MShop\Factory::clear(); }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->view)) { if (($pos = $view->param('l_pos')) !== null && ($pid = $view->param('d_prodid')) !== null) { if ($pos < 1) { $start = 0; $size = 2; } else { $start = $pos - 1; $size = 3; } $context = $this->getContext(); $site = $context->getLocale()->getSite()->getCode(); $params = $context->getSession()->get('aimeos/catalog/lists/params/last/' . $site, array()); $filter = $this->getProductListFilterByParam($params); $filter->setSlice($start, $size); $total = null; $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $products = $controller->getIndexItems($filter, array('text'), $total); if (($count = count($products)) > 1) { $enc = $view->encoder(); $listPos = array_search($pid, array_keys($products)); $target = $view->config('client/html/catalog/detail/url/target'); $controller = $view->config('client/html/catalog/detail/url/controller', 'catalog'); $action = $view->config('client/html/catalog/detail/url/action', 'detail'); $config = $view->config('client/html/catalog/detail/url/config', array()); if ($listPos > 0 && ($product = reset($products)) !== false) { $param = array('d_prodid' => $product->getId(), 'd_name' => $enc->url($product->getName('url ')), 'l_pos' => $pos - 1); $view->navigationPrev = $view->url($target, $controller, $action, $param, array(), $config); } if ($listPos < $count - 1 && ($product = end($products)) !== false) { $param = array('d_prodid' => $product->getId(), 'd_name' => $enc->url($product->getName('url')), 'l_pos' => $pos + 1); $view->navigationNext = $view->url($target, $controller, $action, $param, array(), $config); } } } $this->view = $view; } return $this->view; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $params = $this->getClientParams($view->param(), array('f', 'l')); if (isset($params['f_catid']) && $params['f_catid'] != '') { $context = $this->getContext(); $config = $context->getConfig(); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $default = array('attribute', 'media', 'text'); /** client/html/catalog/domains * A list of domain names whose items should be available in the catalog view templates * * @see client/html/catalog/stage/domains */ $domains = $config->get('client/html/catalog/domains', $default); /** client/html/catalog/stage/standard/domains * A list of domain names whose items should be available in the catalog stage view template * * The templates rendering the catalog stage section use the texts and * maybe images and attributes associated to the categories. You can * configure your own list of domains (attribute, media, price, product, * text, etc. are domains) whose items are fetched from the storage. * Please keep in mind that the more domains you add to the configuration, * the more time is required for fetching the content! * * This configuration option overwrites the "client/html/catalog/domains" * option that allows to configure the domain names of the items fetched * for all catalog related data. * * @param array List of domain names * @since 2014.03 * @category Developer * @see client/html/catalog/domains * @see client/html/catalog/detail/domains * @see client/html/catalog/lists/domains */ $domains = $config->get('client/html/catalog/stage/standard/domains', $domains); $stageCatPath = $controller->getCatalogPath($params['f_catid'], $domains); if (($categoryItem = end($stageCatPath)) !== false) { $view->stageCurrentCatItem = $categoryItem; } $this->addMetaItems($stageCatPath, $this->expire, $this->tags); $view->stageCatPath = $stageCatPath; } $view->stageParams = $params; $this->cache = $view; } $expire = $this->expires($this->expire, $expire); $tags = array_merge($tags, $this->tags); return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $context = $this->getContext(); $basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $serviceCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'service'); $basket = $basketCntl->get(); $services = $serviceCntl->getServices('payment', $basket); $serviceAttributes = $servicePrices = array(); foreach ($services as $id => $service) { $serviceAttributes[$id] = $serviceCntl->getServiceAttributes('payment', $id, $basket); $servicePrices[$id] = $serviceCntl->getServicePrice('payment', $id, $basket); } $view->paymentServices = $services; $view->paymentServiceAttributes = $serviceAttributes; $view->paymentServicePrices = $servicePrices; $this->cache = $view; } return $this->cache; }
/** * Sets the necessary parameter values in the view. * * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output * @param array &$tags Result array for the list of tags that are associated to the output * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) * @return \Aimeos\MW\View\Iface Modified view object */ protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) { if (!isset($this->cache)) { $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket'); $view->miniBasket = $controller->get(); $this->cache = $view; } return $this->cache; }
/** * Returns the catalog controller object * * @return \Aimeos\Controller\Frontend\Catalog\Interface Catalog controller */ protected function getCatalogController() { if (!isset($this->controller)) { $context = $this->getContext(); $this->controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); } return $this->controller; }