/** * 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(); $basketCntl = Controller_Frontend_Factory::createController($this->_getContext(), '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; } }
/** * 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 = Controller_Frontend_Factory::createController($this->_getContext(), 'basket'); $controller->get()->check(MShop_Order_Item_Base_Abstract::PARTS_ALL); parent::process(); } catch (Exception $e) { $view->standardStepActive = 'summary'; throw $e; } }
/** * 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() { $refresh = false; $view = $this->getView(); $context = $this->_getContext(); $session = $context->getSession(); $str = $session->get('arcavias/catalog/session/pinned/list'); if (($pinned = @unserialize($str)) === false) { $pinned = array(); } switch ($view->param('pin-action')) { case 'add': foreach ((array) $view->param('pin-id', array()) as $id) { $pinned[$id] = $id; } /** client/html/catalog/session/pinned/default/maxitems * Maximum number of products displayed in the "pinned" section * * This option limits the number of products that are shown in the * "pinned" section after the users added the product to their list * of pinned products. It must be a positive integer value greater * than 0. * * Note: The higher the value is the more data has to be transfered * to the client each time the user loads a page with the list of * pinned products. * * @param integer Number of products * @since 2014.09 * @category User * @category Developer */ $max = $context->getConfig()->get('client/html/catalog/session/pinned/default/maxitems', 50); $pinned = array_slice($pinned, -$max, $max, true); $refresh = true; break; case 'delete': foreach ((array) $view->param('pin-id', array()) as $id) { unset($pinned[$id]); } $refresh = true; break; } if ($refresh) { $session->set('arcavias/catalog/session/pinned/list', serialize($pinned)); foreach ($session->get('arcavias/catalog/session/pinned/cache', array()) as $key => $value) { $session->set($key, null); } } parent::process(); }
/** * Initializes the object instance * * @param MShop_Context_Item_Interface $context Context object with required objects * @param array $templatePaths Associative list of the file system paths to the core or the extensions as key * and a list of relative paths inside the core or the extension as values * @param Client_Html_Interface $client Client object */ public function __construct(MShop_Context_Item_Interface $context, array $templatePaths) { parent::__construct($context, $templatePaths); }
/** * 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 { $context = $this->_getContext(); $basketCtrl = Controller_Frontend_Factory::createController($context, 'basket'); // only start if there's something to do if (($serviceId = $view->param('c-delivery-option', null)) !== null) { $serviceCtrl = Controller_Frontend_Factory::createController($context, 'service'); $attributes = $view->param('c-delivery/' . $serviceId, array()); $errors = $serviceCtrl->checkServiceAttributes('delivery', $serviceId, $attributes); foreach ($errors as $key => $msg) { if ($msg === null) { unset($errors[$key]); } } if (count($errors) === 0) { $basketCtrl->setService('delivery', $serviceId, $attributes); } else { $view->standardStepActive = 'delivery'; } $view->deliveryError = $errors; } parent::process(); // Test if delivery service is available $services = $basketCtrl->get()->getServices(); if (!isset($view->standardStepActive) && !array_key_exists('delivery', $services)) { $view->standardStepActive = 'delivery'; return false; } } catch (Exception $e) { $view->standardStepActive = 'delivery'; throw $e; } }
/** * 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(); try { parent::process(); } catch (Client_Html_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('client/html', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('controller/frontend', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (MShop_Plugin_Provider_Exception $e) { $errors = array($this->_getContext()->getI18n()->dt('mshop', $e->getMessage())); $errors = array_merge($errors, $this->_translatePluginErrorCodes($e->getErrorCodes())); $view->summaryErrorCodes = $e->getErrorCodes(); $view->standardErrorList = $view->get('standardErrorList', array()) + $errors; } catch (MShop_Exception $e) { $error = array($this->_getContext()->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/html', 'A non-recoverable error occured')); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } }
/** * Processes the input, e.g. provides the address form. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $basket = $view->orderBasket; $customerId = $basket->getCustomerId(); try { $addr = $basket->getAddress(MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY); if ($customerId != '' && $addr->getAddressId() == '') { $addrManager = MShop_Factory::createManager($this->_getContext(), 'customer/address'); $orderAddrManager = MShop_Factory::createManager($this->_getContext(), 'order/base/address'); $item = $addrManager->createItem(); $item->setRefId($customerId); $item->copyFrom($addr); $addrManager->saveItem($item); $addr->setAddressId($item->getId()); $orderAddrManager->saveItem($addr, false); } } catch (Exception $e) { $msg = sprintf('Unable to save address for customer "%1$s": %2$s', $customerId, $e->getMessage()); $this->_getContext()->getLogger()->log($msg, MW_Logger_Abstract::DEBUG); } parent::process(); }
/** * 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(); // only start if there's something to do if (($option = $view->param('cs-option-terms', null)) === null) { return; } if (($option = $view->param('cs-option-terms-value', 0)) != 1) { $view->standardStepActive = 'summary'; $view->termsError = true; $error = array($view->translate('client/html', 'Please accept the terms and conditions')); $view->standardErrorList = $error + $view->get('standardErrorList', array()); } parent::process(); }
/** * 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 = MShop_Factory::createManager($context, 'order/base'); $basket = $orderBaseManager->getSession(); $basket->setCustomerId($context->getUserId()); $basket->finish(); $cntl = Controller_Frontend_Factory::createController($context, 'order'); $orderItem = $cntl->store($basket); $cntl->block($orderItem); $context->getSession()->set('arcavias/orderid', $orderItem->getId()); $view->orderItem = $orderItem; $view->orderBasket = $basket; parent::process(); // save again after sub-clients modified it's state MShop_Factory::createManager($context, 'order')->saveItem($orderItem); } catch (Exception $e) { $view->standardStepActive = 'order'; throw $e; } }
/** * Stores the given or fetched billing address in the basket. */ public function process() { $context = $this->_getContext(); $view = $this->getView(); try { if (($id = $view->param('ca-delivery-delete', null)) !== null) { $customerAddressManager = MShop_Factory::createManager($context, 'customer/address'); $address = $customerAddressManager->getItem($id); if ($address->getRefId() != $context->getUserId()) { throw new Client_Html_Exception(sprintf('Address with ID "%1$s" not found', $id)); } $customerAddressManager->deleteItem($id); } // only start if there's something to do if ($view->param('ca-delivery-option', null) === null) { return; } $basketCtrl = Controller_Frontend_Factory::createController($context, 'basket'); /** client/html/common/address/delivery/disable-new * Disables the option to enter a different delivery address for an order * * Besides the billing address, customers can usually enter a different * delivery address as well. To suppress displaying the form fields for * a delivery address, you can set this configuration option to "1". * * @param boolean A value of "1" to disable, "0" enables the delivery address form * @since 2014.03 * @category User * @category Developer * @see client/html/common/address/delivery/salutations * @see client/html/common/address/delivery/mandatory * @see client/html/common/address/delivery/optional * @see client/html/common/address/delivery/hidden */ $disable = $view->config('client/html/common/address/delivery/disable-new', false); $type = MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY; if (($option = $view->param('ca-delivery-option', 'null')) === 'null' && $disable === false) { $params = $view->param('ca-delivery', array()); $invalid = $this->_checkFields($params); if (count($invalid) > 0) { $view->deliveryError = $invalid; throw new Client_Html_Exception(sprintf('At least one delivery address part is missing or invalid')); } $basketCtrl->setAddress($type, $params); } else { if (($option = $view->param('ca-delivery-option', 'null')) !== '-1') { $customerAddressManager = MShop_Factory::createManager($context, 'customer/address'); $address = $customerAddressManager->getItem($option); if ($address->getRefId() != $context->getUserId()) { throw new Client_Html_Exception(sprintf('Address with ID "%1$s" not found', $option)); } $invalid = array(); $params = $view->param('ca-delivery-' . $option, array()); if (!empty($params)) { $list = array(); $invalid = $this->_checkFields($params); foreach ($params as $key => $value) { $list[str_replace('order.base', 'customer', $key)] = $value; } $address->fromArray($list); $customerAddressManager->saveItem($address); } if (count($invalid) > 0) { $view->deliveryError = $invalid; throw new Client_Html_Exception(sprintf('At least one delivery address part is missing or invalid')); } $basketCtrl->setAddress($type, $address); } else { $basketCtrl->setAddress($type, null); } } parent::process(); } catch (Controller_Frontend_Exception $e) { $view->deliveryError = $e->getErrorList(); throw $e; } }
/** * Initializes the client decorator. * * @param MShop_Context_Item_Interface $context Context object with required objects * @param array $templatePaths Associative list of the file system paths to the core or the extensions as key * and a list of relative paths inside the core or the extension as values * @param Client_Html_Interface $client Client object */ public function __construct(MShop_Context_Item_Interface $context, array $templatePaths, Client_Html_Interface $client) { parent::__construct($context, $templatePaths); $this->_client = $client; }
/** * Processes the input, e.g. provides the payment form. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $basket = $view->orderBasket; $orderItem = $view->orderItem; $context = $this->_getContext(); /** client/html/checkout/confirm/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/confirm/url/controller * @see client/html/checkout/confirm/url/action * @see client/html/checkout/confirm/url/config */ $target = $view->config('client/html/checkout/confirm/url/target'); /** client/html/checkout/confirm/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/confirm/url/target * @see client/html/checkout/confirm/url/action * @see client/html/checkout/confirm/url/config */ $controller = $view->config('client/html/checkout/confirm/url/controller', 'checkout'); /** client/html/checkout/confirm/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/confirm/url/target * @see client/html/checkout/confirm/url/controller * @see client/html/checkout/confirm/url/config */ $action = $view->config('client/html/checkout/confirm/url/action', 'confirm'); /** client/html/checkout/confirm/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/confirm/url/target * @see client/html/checkout/confirm/url/controller * @see client/html/checkout/confirm/url/action * @see client/html/url/config */ $config = $view->config('client/html/checkout/confirm/url/config', array('absoluteUri' => true)); $confirmUrl = $view->url($target, $controller, $action, array(), 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 */ $controller = $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', array('absoluteUri' => true)); $updateUrl = $view->url($target, $controller, $action, array(), array(), $config); $config = array('payment.url-success' => $confirmUrl, 'payment.url-update' => $updateUrl); try { $service = $basket->getService('payment'); $manager = MShop_Factory::createManager($context, 'service'); $provider = $manager->getProvider($manager->getItem($service->getServiceId())); $provider->injectGlobalConfigBE($config); $view->paymentForm = $provider->process($orderItem); } catch (MShop_Order_Exception $e) { $view->paymentForm = new MShop_Common_Item_Helper_Form_Default($confirmUrl, 'REDIRECT'); } if (!isset($view->paymentForm) || $view->paymentForm === null) { $msg = sprintf('Invalid process response from service provider with code "%1$s"', $service->getCode()); throw new Client_Html_Exception($msg); } parent::process(); }
/** * 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(); $ids = $view->param('fav-id', array()); if ($context->getUserId() != null && !empty($ids)) { $typeItem = $this->_getTypeItem(); $manager = MShop_Factory::createManager($context, 'customer/list'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.list.parentid', $context->getUserId()), $search->compare('==', 'customer.list.refid', $ids), $search->compare('==', 'customer.list.domain', 'product'), $search->compare('==', 'customer.list.typeid', $typeItem->getId())); $search->setConditions($search->combine('&&', $expr)); $items = array(); foreach ($manager->searchItems($search) as $item) { $items[$item->getRefId()] = $item; } switch ($view->param('fav-action')) { case 'add': $item = $manager->createItem(); $item->setParentId($context->getUserId()); $item->setTypeId($typeItem->getId()); $item->setDomain('product'); $item->setStatus(1); foreach ((array) $view->param('fav-id', array()) as $id) { if (!isset($items[$id])) { $item->setId(null); $item->setRefId($id); $manager->saveItem($item); $manager->moveItem($item->getId()); } } break; case 'delete': $listIds = array(); foreach ((array) $view->param('fav-id', array()) as $id) { if (isset($items[$id])) { $listIds[] = $items[$id]->getId(); } } $manager->deleteItems($listIds); break; } } parent::process(); }
/** * 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() { $context = $this->_getContext(); try { $params = $this->getView()->param(); $orderid = $context->getSession()->get('arcavias/orderid'); $serviceManager = MShop_Factory::createManager($context, 'service'); $search = $serviceManager->createSearch(); $search->setConditions($search->compare('==', 'service.type.code', 'payment')); $search->setSortations(array($search->sort('+', 'service.position'))); $start = 0; do { $serviceItems = $serviceManager->searchItems($search); foreach ($serviceItems as $serviceItem) { try { $provider = $serviceManager->getProvider($serviceItem); if (($orderItem = $provider->updateSync($params)) !== null) { if ($orderItem->getPaymentStatus() === MShop_Order_Item_Abstract::PAY_UNFINISHED && $provider->isImplemented(MShop_Service_Provider_Payment_Abstract::FEAT_QUERY)) { $provider->query($orderItem); } break 2; } } catch (Exception $e) { $msg = 'Updating order ID "%1$s" failed: %2$s'; $context->getLogger()->log(sprintf($msg, $orderid, $e->getMessage())); } } $count = count($serviceItems); $start += $count; $search->setSlice($start); } while ($count >= $search->getSliceSize()); parent::process(); $orderManager = MShop_Factory::createManager($context, 'order'); $orderItem = $orderManager->getItem($orderid); // Clear basket and cache if ($orderItem->getPaymentStatus() > MShop_Order_Item_Abstract::PAY_REFUSED) { $session = $context->getSession(); foreach ($session->get('arcavias/basket/cache', array()) as $key => $value) { $session->set($key, null); } $orderBaseManager = MShop_Factory::createManager($context, 'order/base'); $orderBaseManager->setSession($orderBaseManager->createItem()); } // Update stock, coupons, etc. Controller_Frontend_Factory::createController($context, 'order')->update($orderItem); } catch (Client_Html_Exception $e) { $view = $this->getView(); $error = array($context->getI18n()->dt('client/html', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $view = $this->getView(); $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (MShop_Exception $e) { $view = $this->getView(); $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $view = $this->getView(); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } }
/** * Stores the given or fetched billing address in the basket. */ public function process() { $view = $this->getView(); try { // only start if there's something to do if ($view->param('ca-billing-option', null) === null) { return; } $context = $this->_getContext(); $basketCtrl = Controller_Frontend_Factory::createController($context, 'basket'); /** client/html/common/address/billing/disable-new * Disables the option to enter a new billing address for an order * * Besides the main billing address, customers can usually enter a new * billing address as well. To suppress displaying the form fields for * a billing address, you can set this configuration option to "1". * * @param boolean A value of "1" to disable, "0" enables the billing address form * @since 2014.03 * @category User * @category Developer * @see client/html/common/address/billing/salutations * @see client/html/common/address/billing/mandatory * @see client/html/common/address/billing/optional * @see client/html/common/address/billing/hidden */ $disable = $view->config('client/html/common/address/billing/disable-new', false); $type = MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT; if (($option = $view->param('ca-billing-option', 'null')) === 'null' && $disable === false) { $params = $view->param('ca-billing', array()); $invalid = $this->_checkFields($params); if (count($invalid) > 0) { $view->billingError = $invalid; throw new Client_Html_Exception(sprintf('At least one billing address part is missing or invalid')); } $basketCtrl->setAddress($type, $params); } else { $customerManager = MShop_Factory::createManager($context, 'customer'); $search = $customerManager->createSearch(true); $expr = array($search->compare('==', 'customer.id', $option), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $items = $customerManager->searchItems($search); if (($item = reset($items)) === false || $option != $context->getUserId()) { throw new Client_Html_Exception(sprintf('Customer with ID "%1$s" not found', $option)); } $invalid = array(); $addr = $item->getPaymentAddress(); $params = $view->param('ca-billing-' . $option, array()); if (!empty($params)) { $list = array(); $invalid = $this->_checkFields($params); foreach ($params as $key => $value) { $list[str_replace('order.base', 'customer', $key)] = $value; } $addr->fromArray($list); $item->setPaymentAddress($addr); $customerManager->saveItem($item); } if (count($invalid) > 0) { $view->billingError = $invalid; throw new Client_Html_Exception(sprintf('At least one billing address part is missing or invalid')); } $basketCtrl->setAddress($type, $addr); } parent::process(); } catch (Controller_Frontend_Exception $e) { $view->billingError = $e->getErrorList(); throw $e; } }
/** * 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() { if (($id = $this->getView()->param('d-product-id')) !== null) { $context = $this->_getContext(); $session = $context->getSession(); $lastSeen = $session->get('arcavias/catalog/session/seen/list', array()); if (isset($lastSeen[$id])) { $html = $lastSeen[$id]; unset($lastSeen[$id]); $lastSeen[$id] = $html; } else { /** client/html/catalog/session/seen/default/maxitems * Maximum number of products displayed in the "last seen" section * * This option limits the number of products that are shown in the * "last seen" section after the user visited their detail pages. It * must be a positive integer value greater than 0. * * @param integer Number of products * @since 2014.03 * @category User * @category Developer */ $max = $this->_getContext()->getConfig()->get('client/html/catalog/session/seen/default/maxitems', 6); $lastSeen[$id] = $this->_getHtml($id); $lastSeen = array_slice($lastSeen, -$max, $max, true); } $session->set('arcavias/catalog/session/seen/list', $lastSeen); foreach ($session->get('arcavias/catalog/session/seen/cache', array()) as $key => $value) { $session->set($key, null); } } parent::process(); }
/** * 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(); $session = $this->_getContext()->getSession(); if (($languageId = $view->param('loc-languageid')) !== null) { $session->set('arcavias/locale/languageid', $languageId); } if (($currencyId = $view->param('loc-currencyid')) !== null) { $session->set('arcavias/locale/currencyId', $currencyId); } parent::process(); }
/** * 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() { $context = $this->_getContext(); $view = $this->getView(); try { $params = $this->_getClientParams($view->param()); $context->getSession()->set('arcavias/catalog/detail/params/last', $params); parent::process(); } catch (Client_Html_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('client/html', $e->getMessage())); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('controller/frontend', $e->getMessage())); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } catch (MShop_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('mshop', $e->getMessage())); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } catch (Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } }
/** * 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() { try { parent::process(); } catch (Client_Html_Exception $e) { $view = $this->getView(); $error = array($this->_getContext()->getI18n()->dt('client/html', $e->getMessage())); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $view = $this->getView(); $error = array($this->_getContext()->getI18n()->dt('controller/frontend', $e->getMessage())); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } catch (MShop_Exception $e) { $view = $this->getView(); $error = array($this->_getContext()->getI18n()->dt('mshop', $e->getMessage())); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } catch (Exception $e) { $context = $this->_getContext(); $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $view = $this->getView(); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } }
/** * 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(); $ids = $view->param('watch-id', array()); if ($context->getUserId() != null && !empty($ids)) { $typeItem = $this->_getTypeItem(); $manager = MShop_Factory::createManager($context, 'customer/list'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.list.parentid', $context->getUserId()), $search->compare('==', 'customer.list.refid', $ids), $search->compare('==', 'customer.list.domain', 'product'), $search->compare('==', 'customer.list.typeid', $typeItem->getId())); $search->setConditions($search->combine('&&', $expr)); $items = array(); foreach ($manager->searchItems($search) as $item) { $items[$item->getRefId()] = $item; } switch ($view->param('watch-action')) { case 'add': $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.list.parentid', $context->getUserId()), $search->compare('==', 'customer.list.typeid', $typeItem->getId()), $search->compare('==', 'customer.list.domain', 'product')); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, 0); $total = 0; $manager->searchItems($search, array(), $total); /** client/html/account/watch/default/maxitems * Maximum number of products that can be watched in parallel * * This option limits the number of products that can be watched * after the users added the products to their watch list. * It must be a positive integer value greater than 0. * * Note: It's recommended to set this value not too high as this * leads to a high memory consumption when the e-mails are generated * to notify the customers. The memory used will up to 100*maxitems * of the footprint of one product item including the associated * texts, prices and media. * * @param integer Number of products * @since 2014.09 * @category User * @category Developer */ $max = $context->getConfig()->get('client/html/account/watch/default/maxitems', 100); $item = $manager->createItem(); $item->setParentId($context->getUserId()); $item->setTypeId($typeItem->getId()); $item->setDomain('product'); $item->setStatus(1); foreach ((array) $view->param('watch-id', array()) as $id) { if ($total >= $max) { $error = array(sprintf($context->getI18n()->dt('client/html', 'You can only watch up to %1$s products'), $max)); $view->watchErrorList = $view->get('watchErrorList', array()) + $error; break; } if (!isset($items[$id])) { $item->setId(null); $item->setRefId($id); $manager->saveItem($item); $manager->moveItem($item->getId()); $total++; } } break; case 'edit': foreach ((array) $view->param('watch-id', array()) as $id) { if (isset($items[$id])) { $item = $items[$id]; $config = array('timeframe' => $view->param('watch-timeframe', 7), 'price-value' => $view->param('watch-price-value', '0.00'), 'price' => $view->param('watch-price', 0), 'stock' => $view->param('watch-stock', 0)); $time = time() + ($config['timeframe'] + 1) * 86400; $item->setDateEnd(date('Y-m-d 00:00:00', $time)); $item->setConfig($config); $manager->saveItem($item); } } break; case 'delete': $listIds = array(); foreach ((array) $view->param('watch-id', array()) as $id) { if (isset($items[$id])) { $listIds[] = $items[$id]->getId(); } } $manager->deleteItems($listIds); break; } } parent::process(); }
/** * 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() { try { parent::process(); } catch (Exception $e) { $this->_getContext()->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); } }
/** * 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(); try { $orderCntl = Controller_Frontend_Factory::createController($context, 'order'); $serviceManager = MShop_Factory::createManager($context, 'service'); $search = $serviceManager->createSearch(); $search->setSortations(array($search->sort('+', 'service.position'))); $start = 0; do { $serviceItems = $serviceManager->searchItems($search); foreach ($serviceItems as $serviceItem) { $provider = $serviceManager->getProvider($serviceItem); if (($orderItem = $provider->updateSync($view->param())) !== null) { // Update stock, coupons, etc. $orderCntl->update($orderItem); break 2; } } $count = count($serviceItems); $start += $count; $search->setSlice($start); } while ($count >= $search->getSliceSize()); parent::process(); } catch (Exception $e) { $view->updateHttpCode = 500; $view->updateHttpString = 'HTTP/1.1 500 Error updating order status'; $view->updateError = $e->getMessage(); $msg = "Updating order status failed: %1\$s\n%2\$s"; $context->getLogger()->log(sprintf($msg, $e->getMessage(), print_r($view->param(), true))); } }