/** * Returns the list of domains that are available as resources * * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter * @return array List of domain names */ protected function getDomains(\Aimeos\MW\View\Iface $view) { if (($domains = $view->param('resource')) == '') { /** admin/jsonadm/domains * A list of domain names whose clients are available for the JSON API * * The HTTP OPTIONS method returns a list of resources known by the * JSON API including their URLs. The list of available resources * can be exteded dynamically be implementing a new Jsonadm client * class handling request for this new domain. * * To add the new domain client to the list of resources returned * by the HTTP OPTIONS method, you have to add its name in lower case * to the existing configuration. * * @param array List of domain names * @since 2016.01 * @category Developer */ $default = array('attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text'); $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); } return (array) $domains; }
/** * Updates existing product text items or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $id = $view->item->getId(); $context = $this->getContext(); $types = array('name', 'short', 'long', 'url', 'meta-keyword', 'meta-description'); $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); $textManager = \Aimeos\MShop\Factory::createManager($context, 'text'); $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); $listTypeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); $listIds = array(); $langIds = (array) $view->param('text/langid', array()); $listItems = $manager->getItem($id, array('text'))->getListItems('text'); $listItem = $listManager->createItem(); $listItem->setTypeId($listTypeManager->findItem('default', array(), 'text')->getId()); $listItem->setDomain('text'); $listItem->setParentId($id); $listItem->setStatus(1); $textItem = $textManager->createItem(); $textItem->setDomain('product'); $textItem->setStatus(1); foreach ($langIds as $idx => $langid) { foreach ($types as $type) { $content = trim($view->param('text/' . $type . '/content/' . $idx)); $listid = $view->param('text/' . $type . '/listid' . $idx); $listIds[] = $listid; if (!isset($listItems[$listid])) { $litem = $listItem; $litem->setId(null); $item = $textItem; $item->setId(null); } else { $litem = $listItems[$listid]; $item = $litem->getRefItem(); } $item->setContent($content); $item->setLabel(mb_strcut($item->getContent(), 0, 255)); $item->setTypeId($this->getTypeId($type)); $item->setLanguageId($langid); $textManager->saveItem($item); $litem->setPosition($idx); $litem->setRefId($item->getId()); $listManager->saveItem($litem, false); } } $rmIds = array(); $rmListIds = array_diff(array_keys($listItems), $listIds); foreach ($rmListIds as $id) { $rmIds[] = $listItems[$id]->getRefId(); } $listManager->deleteItems($rmListIds); $textManager->deleteItems($rmIds); }
/** * 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(); $prodid = $view->param('d_prodid'); $domains = array('media', 'price', 'text', 'attribute', 'product'); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog'); $productItem = $this->getProductItem($prodid, $domains); $this->addMetaItems($productItem, $this->expire, $this->tags); $productManager = $controller->createManager('product'); $productIds = array_keys($productItem->getRefItems('product')); $products = $this->getDomainItems($productManager, 'product.id', $productIds, $domains); $attrIds = array_keys($productItem->getRefItems('attribute')); $mediaIds = array_keys($productItem->getRefItems('media')); foreach ($products as $product) { $attrIds = array_merge($attrIds, array_keys($product->getRefItems('attribute'))); $mediaIds = array_merge($mediaIds, array_keys($product->getRefItems('media'))); } $attributeManager = $controller->createManager('attribute'); $attributeItems = $this->getDomainItems($attributeManager, 'attribute.id', $attrIds, $domains); $this->addMetaItems($attributeItems, $this->expire, $this->tags); $mediaManager = $controller->createManager('media'); $mediaItems = $this->getDomainItems($mediaManager, 'media.id', $mediaIds, $domains); $this->addMetaItems($mediaItems, $this->expire, $this->tags); $propertyManager = $controller->createManager('product/property'); $propertyItems = $this->getDomainItems($propertyManager, 'product.property.parentid', $productIds, $domains); $view->detailProductItem = $productItem; $view->detailProductItems = $products; $view->detailPropertyItems = $propertyItems; $view->detailAttributeItems = $attributeItems; $view->detailMediaItems = $mediaItems; $view->detailUserId = $context->getUserId(); $view->detailParams = $this->getClientParams($view->param()); $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)) { $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(); $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)) { $config = $this->getContext()->getConfig(); /** client/html/catalog/count/enable * Enables or disables displaying product counts in the catalog filter * * This configuration option allows shop owners to display product * counts in the catalog filter or to disable fetching product count * information. * * The product count information is fetched via AJAX and inserted via * Javascript. This allows to cache parts of the catalog filter by * leaving out such highly dynamic content like product count which * changes with used filter parameter. * * @param boolean Value of "1" to display product counts, "0" to disable them * @since 2014.03 * @category User * @category Developer * @see client/html/catalog/count/url/target * @see client/html/catalog/count/url/controller * @see client/html/catalog/count/url/action * @see client/html/catalog/count/url/config */ if ($config->get('client/html/catalog/count/enable', true) == true) { /** client/html/catalog/count/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/catalog/count/url/controller * @see client/html/catalog/count/url/action * @see client/html/catalog/count/url/config */ $target = $config->get('client/html/catalog/count/url/target'); /** client/html/catalog/count/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/catalog/count/url/target * @see client/html/catalog/count/url/action * @see client/html/catalog/count/url/config */ $controller = $config->get('client/html/catalog/count/url/controller', 'catalog'); /** client/html/catalog/count/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/catalog/count/url/target * @see client/html/catalog/count/url/controller * @see client/html/catalog/count/url/config */ $action = $config->get('client/html/catalog/count/url/action', 'count'); /** client/html/catalog/count/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/catalog/count/url/target * @see client/html/catalog/count/url/controller * @see client/html/catalog/count/url/action * @see client/html/url/config */ $config = $config->get('client/html/catalog/count/url/config', array()); $params = $this->getClientParams($view->param(), array('f')); $view->filterCountUrl = $view->url($target, $controller, $action, $params, array(), $config); } $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)) { $mediaItems = array(); $catPath = $view->get('stageCatPath', array()); foreach (array_reverse($catPath) as $catItem) { $mediaItems = $catItem->getRefItems('media', 'default', 'stage'); if (!empty($mediaItems)) { break; } } $view->imageItems = $mediaItems; $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)) { $map = array(); $context = $this->getContext(); $config = $context->getConfig(); $locale = $context->getLocale(); /** client/html/locale/select/language/param-name * Name of the parameter that contains the language ID value * * Frameworks and applications normally use its own predefined parameter * that contains the current language ID if they are multi-language * capable. To adapt the Aimeos parameter name to the already used name, * you are able to configure it by using this setting. * * @param string Parameter name for language ID * @since 2015.06 * @see client/html/locale/select/currency/param-name */ $langname = $config->get('client/html/locale/select/language/param-name', 'loc_languageid'); /** client/html/locale/select/currency/param-name * Name of the parameter that contains the currency ID value * * Frameworks and applications normally use its own predefined parameter * that contains the current currency ID if they already support multiple * currencies. To adapt the Aimeos parameter name to the already used name, * you are able to configure it by using this setting. * * @param string Parameter name for currency ID * @since 2015.06 * @see client/html/locale/select/language/param-name */ $curname = $config->get('client/html/locale/select/currency/param-name', 'loc_currencyid'); $manager = \Aimeos\MShop\Factory::createManager($context, 'locale'); $search = $manager->createSearch(true); $search->setSortations(array($search->sort('+', 'locale.position'))); foreach ($manager->searchItems($search) as $item) { $curId = $item->getCurrencyId(); $langId = $item->getLanguageId(); $map[$langId][$curId] = array($langname => $langId, $curname => $curId); } $params = $view->param(); $view->selectMap = $map; $view->selectParams = $params; $view->selectLanguageId = $locale->getLanguageId(); $view->selectCurrencyId = $locale->getCurrencyId(); $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; }
/** * Returns the sanitized sortation from the parameters for the product list. * * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters * @param string &$sortdir Value-result parameter where the sort direction will be stored * @return string Sortation string (relevance, name, price) */ protected function getProductListSort(\Aimeos\MW\View\Iface $view, &$sortdir) { return $this->getProductListSortByParam($view->param(), $sortdir); }
/** * 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)) { $view->actionsParams = $this->getClientParams($view->param()); $view->actionsUserId = $this->getContext()->getUserId(); $this->cache = $view; } return $this->cache; }
/** * Retrieves the item or items and adds the data to the view * * @param \Aimeos\MW\View\Iface $view View instance * @return \Aimeos\MW\View\Iface View instance with additional data assigned */ protected function getItems(\Aimeos\MW\View\Iface $view) { $include = ($include = $view->param('include')) !== null ? explode(',', $include) : array(); $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); $search = $this->initCriteria($manager->createSearch(), $view->param()); $total = 1; if (($id = $view->param('id')) == null) { $view->data = $manager->searchItems($search, array(), $total); $view->listItems = $this->getListItems($view->data, $include); $view->childItems = $this->getChildItems($view->data, $include); } else { $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); $view->listItems = $this->getListItems(array($id => $view->data), $include); $view->childItems = $this->getChildItems(array($view->data), $include); } $view->refItems = $this->getRefItems($view->listItems); $view->total = $total; return $view; }
/** * Updates existing product download references or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $id = $view->item->getId(); $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); $attrManager = \Aimeos\MShop\Factory::createManager($context, 'attribute'); $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); $listItems = $manager->getItem($id, array('attribute'))->getListItems('attribute', 'hidden'); if (($listId = $view->param('download/product.lists.id')) !== null) { if (!isset($listItems[$listId])) { $litem = $this->createListItem($id); $item = $this->createItem(); } else { $litem = $listItems[$listId]; $item = $litem->getRefItem(); } $item->setLabel($view->param('download/attribute.label')); if (($file = $view->value($view->request()->getUploadedFiles(), 'download/file')) !== null) { $item->setCode($this->storeFile($file)); } $attrManager->saveItem($item); $litem->setPosition(0); $litem->setRefId($item->getId()); $listManager->saveItem($litem, false); } $this->cleanupItems($listItems, array($listId)); }
/** * Returns the mapped input parameter or the existing items as expected by the template * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function setData(\Aimeos\MW\View\Iface $view) { $view->characteristicData = (array) $view->param('characteristic', array()); }
/** * Updates existing product bundle references or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); $typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); $item = $manager->createItem(); $item->setParentId($view->item->getId()); $item->setTypeId($typeManager->findItem('default', array(), 'product')->getId()); $item->setDomain('product'); $map = $this->getListItems($view->item->getId()); foreach ((array) $view->param('bundle/product.lists.id', array()) as $pos => $prodid) { if (!isset($map[$prodid])) { $item->setId(null); $item->setRefId($prodid); $item->setPosition($pos); $manager->saveItem($item, false); } else { unset($map[$prodid]); } } $manager->deleteItems($map); }
/** * 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)) { $salutations = array(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS, \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS); try { $salutation = ''; $addr = $view->extAddressItem; if (in_array($addr->getSalutation(), $salutations)) { $salutation = $view->translate('client/code', $addr->getSalutation()); } /// E-mail intro with salutation (%1$s), first name (%2$s) and last name (%3$s) $view->emailIntro = sprintf($view->translate('client', 'Dear %1$s %2$s %3$s'), $salutation, $addr->getFirstName(), $addr->getLastName()); } catch (\Exception $e) { $view->emailIntro = $view->translate('client/html/email', 'Dear Sir or Madam'); } $this->cache = $view; } return $this->cache; }
/** * Adds the "url" helper to the view object * * @param \Aimeos\MW\View\Iface $view View object * @param \TYPO3\Flow\Mvc\Routing\UriBuilder $uriBuilder URL builder object * @param \TYPO3\Flow\Mvc\RequestInterface|null $request Request object * @return \Aimeos\MW\View\Iface Modified view object */ protected function addUrl(\Aimeos\MW\View\Iface $view, \TYPO3\Flow\Mvc\Routing\UriBuilder $uriBuilder, \TYPO3\Flow\Mvc\RequestInterface $request = null) { $fixed = array(); if ($request !== null) { $params = $request->getArguments(); if (isset($params['site'])) { $fixed['site'] = $params['site']; } if (isset($params['locale'])) { $fixed['locale'] = $params['locale']; } if (isset($params['currency'])) { $fixed['currency'] = $params['currency']; } } $helper = new \Aimeos\MW\View\Helper\Url\Flow($view, $uriBuilder, $fixed); $view->addHelper('url', $helper); return $view; }
/** * Updates existing product price references or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $id = $view->item->getId(); $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); $listTypeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); $listIds = (array) $view->param('price/product.lists.id', array()); $listItems = $manager->getItem($id, array('price'))->getListItems('price'); $listItem = $listManager->createItem(); $listItem->setTypeId($listTypeManager->findItem('default', array(), 'price')->getId()); $listItem->setDomain('price'); $listItem->setParentId($id); $listItem->setStatus(1); $priceItem = $priceManager->createItem(); $priceItem->setDomain('product'); $priceItem->setStatus(1); foreach ($listIds as $idx => $listid) { if (!isset($listItems[$listid])) { $litem = $listItem; $litem->setId(null); $item = $priceItem; $item->setId(null); } else { $litem = $listItems[$listid]; $item = $litem->getRefItem(); } $item->setLabel($view->param('price/price.label/' . $idx)); $item->setTypeId($view->param('price/price.typeid/' . $idx)); $item->setCurrencyId($view->param('price/price.currencyid/' . $idx)); $item->setQuantity($view->param('price/price.quantity/' . $idx)); $item->setValue($view->param('price/price.value/' . $idx)); $item->setCosts($view->param('price/price.costs/' . $idx)); $item->setRebate($view->param('price/price.rebate/' . $idx)); $item->setTaxRate($view->param('price/price.taxrate/' . $idx)); $priceManager->saveItem($item); $litem->setPosition($idx); $litem->setRefId($item->getId()); $listManager->saveItem($litem, false); } $rmIds = array(); $rmListIds = array_diff(array_keys($listItems), $listIds); foreach ($rmListIds as $id) { $rmIds[] = $listItems[$id]->getRefId(); } $listManager->deleteItems($rmListIds); $priceManager->deleteItems($rmIds); }
/** * Updates existing product stock items or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'product.stock.parentid', $view->item->getId())); $items = $manager->searchitems($search); $list = (array) $view->param('stock/product.stock.id', array()); foreach ($list as $idx => $id) { if (!isset($items[$id])) { $item = $manager->createItem(); } else { $item = $items[$id]; } $item->setParentId($view->item->getId()); $item->setWarehouseId($view->param('stock/product.stock.warehouseid/' . $idx)); $item->setStocklevel($view->param('stock/product.stock.stocklevel/' . $idx)); $item->setDateBack($view->param('stock/product.stock.dateback/' . $idx)); $manager->saveItem($item, false); } $manager->deleteItems(array_diff(array_keys($items), $list)); }
/** * Updates existing product category references or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists'); $typeManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists/type'); $id = $view->item->getId(); $map = $this->getListItems($id); $listIds = (array) $view->param('category/catalog.lists.id', array()); foreach ($listIds as $pos => $listid) { if (isset($map[$listid])) { unset($map[$listid], $listIds[$pos]); } } $manager->deleteItems(array_keys($map)); $item = $manager->createItem(); $item->setTypeId($typeManager->findItem('default', array(), 'product')->getId()); $item->setDomain('product'); $item->setRefId($id); foreach ($listIds as $pos => $listid) { $item->setId(null); $item->setParentId($view->param('category/catalog.id/' . $pos)); $manager->saveItem($item, false); } }
/** * 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) { /** client/html/email/logo * Path to the logo image displayed in HTML e-mails * * The path can either be an absolute local path or an URL to a file on a * remote server. If the file is stored on a remote server, "allow_url_fopen" * must be enabled. See {@link http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen php.ini allow_url_fopen} * documentation for details. * * @param string Absolute file system path or remote URL to the logo image * @since 2014.03 * @category User * @see client/html/email/from-email */ $file = $view->config('client/html/email/logo', 'client/html/themes/elegance/media/aimeos.png'); if (file_exists($file) && ($content = file_get_contents($file)) !== false) { $finfo = new \finfo(FILEINFO_MIME_TYPE); $mimetype = $finfo->file($file); $view->htmlLogo = $view->mail()->embedAttachment($content, $mimetype, basename($file)); } $path = $view->config('client/html/common/template/baseurl', 'client/html/themes/elegance'); $filepath = $path . DIRECTORY_SEPARATOR . 'common.css'; if (file_exists($filepath) && ($css = file_get_contents($filepath)) !== false) { $view->htmlCss = $css; } return $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)) { $context = $this->getContext(); $customerManager = \Aimeos\MShop\Factory::createManager($context, 'customer'); $search = $customerManager->createSearch(true); $expr = array($search->compare('==', 'customer.id', $context->getUserId()), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $items = $customerManager->searchItems($search); if (($item = reset($items)) !== false) { $deliveryAddressItems = array(); $orderAddressManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/address'); $customerAddressManager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); $search = $customerAddressManager->createSearch(); $search->setConditions($search->compare('==', 'customer.address.parentid', $item->getId())); foreach ($customerAddressManager->searchItems($search) as $id => $address) { $deliveryAddressItem = $orderAddressManager->createItem(); $deliveryAddressItem->copyFrom($address); $deliveryAddressItems[$id] = $deliveryAddressItem; } $paymentAddressItem = $orderAddressManager->createItem(); $paymentAddressItem->copyFrom($item->getPaymentAddress()); $view->addressCustomerItem = $item; $view->addressPaymentItem = $paymentAddressItem; $view->addressDeliveryItems = $deliveryAddressItems; } $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); $locales = $localeManager->searchItems($localeManager->createSearch(true)); $languages = array(); foreach ($locales as $locale) { $languages[$locale->getLanguageId()] = $locale->getLanguageId(); } $view->addressLanguages = $languages; /** client/html/checkout/standard/address/countries * List of available countries that that users can select from in the front-end * * This configration option is used whenever a list of countries is * shown in the front-end users can select from. It's used e.g. * if the customer should select the country he is living in the * checkout process. In case that the list is empty, no country * selection is shown. * * Each list entry must be a two letter ISO country code that is then * translated into its name. The codes have to be upper case * characters like "DE" for Germany or "GB" for Great Britain, e.g. * * array( 'DE', 'GB', ... ) * * To display the country selection, you have to add the key for the * country ID (order.base.address.languageid) to the "mandatory" or * "optional" configuration option for billing and delivery addresses. * * Until 2015-02, the configuration option was available as * "client/html/common/address/countries" starting from 2014-03. * * @param array List of two letter ISO country codes * @since 2015.02 * @category User * @category Developer * @see client/html/checkout/standard/address/billing/mandatory * @see client/html/checkout/standard/address/billing/optional * @see client/html/checkout/standard/address/delivery/mandatory * @see client/html/checkout/standard/address/delivery/optional */ $view->addressCountries = $view->config('client/html/checkout/standard/address/countries', array()); /** client/html/checkout/standard/address/states * List of available states that that users can select from in the front-end * * This configration option is used whenever a list of states is * shown in the front-end users can select from. It's used e.g. * if the customer should select the state he is living in the * checkout process. In case that the list is empty, no state * selection is shown. * * A two letter ISO country code must be the key for the list of * states that belong to this country. The list of states must then * contain the state code as key and its name as values, e.g. * * array( * 'US' => array( * 'CA' => 'California', * 'NY' => 'New York', * ... * ), * ... * ); * * The codes have to be upper case characters like "US" for the * United States or "DE" for Germany. The order of the country and * state codes determine the order of the states in the frontend and * the state codes are later used for per state tax calculation. * * To display the country selection, you have to add the key for the * state (order.base.address.state) to the "mandatory" or * "optional" configuration option for billing and delivery addresses. * You also need to add order.base.address.countryid as well because * it is required to display the states that belong to this country. * * Until 2015-02, the configuration option was available as * "client/html/common/address/states" starting from 2014-09. * * @param array Multi-dimensional list ISO country codes and state codes/names * @since 2015.02 * @category User * @category Developer * @see client/html/checkout/standard/address/billing/mandatory * @see client/html/checkout/standard/address/billing/optional * @see client/html/checkout/standard/address/delivery/mandatory * @see client/html/checkout/standard/address/delivery/optional */ $view->addressStates = $view->config('client/html/checkout/standard/address/states', array()); $view->addressExtra = $context->getSession()->get('client/html/checkout/standard/address/extra', array()); $this->cache = $view; } return $this->cache; }
/** * Maps the input parameter to an associative array as expected by the template * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters * @return array Multi-dimensional associative array */ protected function getDataParams(\Aimeos\MW\View\Iface $view) { $data = array(); foreach ((array) $view->param('selection/product.code', array()) as $pos => $code) { if (!empty($code)) { $data[$code]['product.lists.id'] = $view->param('selection/product.lists.id/' . $pos); $data[$code]['product.id'] = $view->param('selection/product.id/' . $pos); $data[$code]['product.label'] = $view->param('selection/product.label/' . $pos); } } foreach ((array) $view->param('selection/attr/ref', array()) as $pos => $code) { if (!empty($code)) { $id = $view->param('selection/attr/id/' . $pos); $data[$code]['attr'][$id]['ref'] = $code; $data[$code]['attr'][$id]['label'] = $view->param('selection/attr/label/' . $pos); } } return $data; }
/** * 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; }
/** * Maps the item configuration from parameters to a list of key/value pairs * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters * @return array Associative list of key/value pairs */ protected function getItemConfig(\Aimeos\MW\View\Iface $view) { $config = array(); foreach ($view->param('item/config/key') as $idx => $key) { if (trim($key) !== '') { $config[$key] = $view->param('item/config/val/' . $idx); } } return $config; }
/** * Returns the URL to the update page. * * @param \Aimeos\MW\View\Iface $view View object * @param array $params Parameters that should be part of the URL * @param array $config Default URL configuration * @return string URL string */ protected function getUrlUpdate(\Aimeos\MW\View\Iface $view, array $params, array $config) { /** client/html/checkout/update/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/update/url/controller * @see client/html/checkout/update/url/action * @see client/html/checkout/update/url/config */ $target = $view->config('client/html/checkout/update/url/target'); /** client/html/checkout/update/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/update/url/target * @see client/html/checkout/update/url/action * @see client/html/checkout/update/url/config */ $cntl = $view->config('client/html/checkout/update/url/controller', 'checkout'); /** client/html/checkout/update/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/update/url/target * @see client/html/checkout/update/url/controller * @see client/html/checkout/update/url/config */ $action = $view->config('client/html/checkout/update/url/action', 'update'); /** client/html/checkout/update/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/update/url/target * @see client/html/checkout/update/url/controller * @see client/html/checkout/update/url/action * @see client/html/url/config */ $config = $view->config('client/html/checkout/update/url/config', $config); return $view->url($target, $cntl, $action, $params, array(), $config); }
/** * Returns the sanitized page size from the parameters for the product list. * * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters * @return integer Page size */ protected function getProductListSize(\Aimeos\MW\View\Iface $view) { /** client/html/account/favorite/size * The number of products shown in a list page for favorite products * * Limits the number of products that is shown in the list pages to the * given value. If more products are available, the products are split * into bunches which will be shown on their own list page. The user is * able to move to the next page (or previous one if it's not the first) * to display the next (or previous) products. * * The value must be an integer number from 1 to 100. Negative values as * well as values above 100 are not allowed. The value can be overwritten * per request if the "l_size" parameter is part of the URL. * * @param integer Number of products * @since 2014.09 * @category User * @category Developer * @see client/html/catalog/lists/size */ $defaultSize = $this->getContext()->getConfig()->get('client/html/account/favorite/size', 48); $size = (int) $view->param('fav-size', $defaultSize); return $size < 1 || $size > 100 ? $defaultSize : $size; }
/** * 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; }
/** * Updates existing property items or creates new ones * * @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters */ protected function updateItems(\Aimeos\MW\View\Iface $view) { $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager($context, 'product/property'); $typeManager = \Aimeos\MShop\Factory::createManager($context, 'product/property/type'); $ids = array(); $items = $this->getItems($view->item->getId()); foreach ((array) $view->param('physical', array()) as $type => $value) { $value = trim($value); if ($value == '') { if (isset($items[$type])) { $ids[] = $items[$type]->getId(); } continue; } if (!isset($items[$type])) { $items[$type] = $manager->createItem(); $items[$type]->setParentId($view->item->getId()); $items[$type]->setTypeId($typeManager->findItem($type, array(), 'product/property')->getId()); } $items[$type]->setValue($value); $manager->saveItem($items[$type]); } $manager->deleteItems($ids); }