public function recentlyViewedProductsAction() { $env = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); $recentlyViewed = $env->getCustomItem(self::RECENTLY_VIEWED_PRODUCTS); if (!$recentlyViewed) { $recentlyViewed = array(); } $exists = false; if (in_array($this->_getParam('id'), $recentlyViewed)) { $exists = true; } if (!$exists && $this->_getParam('id')) { array_push($recentlyViewed, $this->_getParam('id')); if (count($recentlyViewed) > self::MAX_PRODUCTS + 1) { array_shift($recentlyViewed); } } $env->setCustomItem(self::RECENTLY_VIEWED_PRODUCTS, $recentlyViewed); $env->save(); unset($recentlyViewed[array_search($this->_getParam('id'), $recentlyViewed)]); $products = array(); foreach ($recentlyViewed as $productId) { $products[] = Website_DefaultProduct::getById($productId); } $this->view->products = $products; $this->view->currentId = htmlentities($this->_getParam("id")); $this->renderScript('includes/recently-viewed-products.php'); }
public function getCondition() { $currentSubTenant = OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrentAssortmentSubTenant(); if ($currentSubTenant) { return "b.subtenant_id = " . $currentSubTenant; } else { return ""; } }
/** * @return bool|OnlineShop_Framework_VoucherService_ITokenManager * @throws OnlineShop_Framework_Exception_InvalidConfigException */ public function getTokenManager() { $items = $this->getTokenSettings(); if ($items && $items->get(0)) { // name of fieldcollection class $configuration = $items->get(0); return OnlineShop_Framework_Factory::getInstance()->getTokenManager($configuration); } return false; }
public function __get($name) { $currentCheckoutTenant = OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrentCheckoutTenant(); if ($currentCheckoutTenant && $this->tenantConfigs[$currentCheckoutTenant]) { $option = $this->tenantConfigs[$currentCheckoutTenant]->{$name}; if ($option) { return $option; } } return $this->defaultConfig->{$name}; }
/** * returns shop-instance specific implementation of priceInfo, override this method in your own price system to * set any price values * @param $quantityScale * @param $product * @param $products * @return OnlineShop_Framework_Pricing_IPriceInfo */ protected function initPriceInfoInstance($quantityScale, $product, $products) { $priceInfo = $this->createPriceInfoInstance($quantityScale, $product, $products); $priceInfo->setQuantity($quantityScale); $priceInfo->setProduct($product); $priceInfo->setProducts($products); $priceInfo->setPriceSystem($this); // apply pricing rules $priceInfoWithRules = OnlineShop_Framework_Factory::getInstance()->getPricingManager()->applyProductRules($priceInfo); return $priceInfoWithRules; }
/** * save individually data * @param OnlineShop_Framework_ICart $cart * @param OnlineShop_Framework_AbstractOrder $order */ protected function processOrder(OnlineShop_Framework_ICart $cart, OnlineShop_Framework_AbstractOrder $order) { /* @var Object_OnlineShopOrder $order*/ $checkout = OnlineShop_Framework_Factory::getInstance()->getCheckoutManager($cart); $deliveryAddress = $checkout->getCheckoutStep('deliveryaddress')->getData(); /* @var Website_OnlineShop_Order_DeliveryAddress $deliveryAddress */ // insert delivery address $order->setCustomerName($deliveryAddress->firstname . ' ' . $deliveryAddress->lastname); $order->setCustomerCompany($deliveryAddress->company); $order->setCustomerStreet($deliveryAddress->address); $order->setCustomerZip($deliveryAddress->zip); $order->setCustomerCity($deliveryAddress->city); $order->setCustomerCountry($deliveryAddress->country); $order->setCustomerEmail($deliveryAddress->email); }
protected function checkForUser() { $environment = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); $userId = Zend_Auth::getInstance()->getIdentity(); $user = Object_Customer::getById($userId); if ($user) { $this->currentUser = $user; $this->view->currentUser = $user; $environment->setUseGuestCart(false); $environment->setCurrentUserId($user->getId()); $environment->save(); } else { $environment->setUseGuestCart(true); $environment->save(); } }
public function __construct() { $indexColumns = array(); try { $indexService = \OnlineShop_Framework_Factory::getInstance()->getIndexService(); $indexColumns = $indexService->getIndexAttributes(true); } catch (\Exception $e) { \Logger::err($e); } $options = array(); foreach ($indexColumns as $c) { $options[] = array("key" => $c, "value" => $c); } if ($this->getSpecificPriceField()) { $options[] = array("key" => \OnlineShop_Framework_IProductList::ORDERKEY_PRICE, "value" => \OnlineShop_Framework_IProductList::ORDERKEY_PRICE); } $this->setOptions($options); }
public function gridAction() { if ($this->_getParam("pimcore_editmode") == "true") { $this->editmode = true; $this->view->editmode = true; } /** * @var $filterDefinition \Pimcore\Model\Object\FilterDefinition */ $filterDefinition = $this->_getParam("filterdefinition"); if (!$filterDefinition instanceof \Pimcore\Model\Object\FilterDefinition) { $filterDefinition = \Pimcore\Model\Object\FilterDefinition::getById(intval($this->_getParam("filterdef"))); if (!$filterDefinition) { throw new Exception("Filter Definition not found!"); } } $this->view->filterDefinitionObject = $filterDefinition; $indexService = OnlineShop_Framework_Factory::getInstance()->getIndexService(); $productList = $indexService->getProductListForCurrentTenant(); $productList->setVariantMode(OnlineShop_Framework_IProductList::VARIANT_MODE_INCLUDE_PARENT_OBJECT); $filterService = OnlineShop_Framework_Factory::getInstance()->getFilterService($this->view); $orderByOptions = array(); $this->view->orderByOptions = $orderByOptions; OnlineShop_Framework_FilterService_Helper::setupProductList($filterDefinition, $productList, $this->_getAllParams(), $this->view, $filterService, $this->_getParam("fullpage")); $this->view->productList = $productList; $this->view->filterService = $filterService; //Getting seo text - if not specified in the template, then get them from the category if existent $grid_seo_headline = $this->view->input("grid_seo_headline")->getValue(); if (empty($grid_seo_headline)) { $category = OnlineShop_Framework_FilterService_Helper::getFirstFilteredCategory($this->view->filterDefinitionObject->getConditions()); if ($category) { $grid_seo_headline = $category->getSeoname(); } } $grid_seo_text = $this->view->wysiwyg("grid_seo_text")->getValue(); if (empty($grid_seo_text)) { $category = OnlineShop_Framework_FilterService_Helper::getFirstFilteredCategory($this->view->filterDefinitionObject->getConditions()); if ($category) { $grid_seo_text = $category->getSeotext(); } } $this->view->grid_seo_headline = $grid_seo_headline; $this->view->grid_seo_text = $grid_seo_text; }
/** * @param Zend_Config $xml * * @throws Exception */ public function __construct(Zend_Config $xml) { $settings = $xml->config->{$xml->mode}; if ($settings->sign == '' || $settings->merchantId == '') { throw new Exception('payment configuration is wrong. secret or customer is empty !'); } $this->merchantId = $settings->merchantId; $this->sign = $settings->sign; if ($xml->mode == 'live') { $this->endpoint['form'] = 'https://payment.datatrans.biz/upp/jsp/upStart.jsp'; $this->endpoint['xmlAuthorize'] = 'https://payment.datatrans.biz/upp/jsp/XML_authorize.jsp'; $this->endpoint['xmlProcessor'] = 'https://payment.datatrans.biz/upp/jsp/XML_processor.jsp'; } else { $this->endpoint['form'] = 'https://pilot.datatrans.biz/upp/jsp/upStart.jsp'; $this->endpoint['xmlAuthorize'] = 'https://pilot.datatrans.biz/upp/jsp/XML_authorize.jsp'; $this->endpoint['xmlProcessor'] = 'https://pilot.datatrans.biz/upp/jsp/XML_processor.jsp'; } $this->currencyLocale = OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrencyLocale(); }
/** * @param string $cartName * * @return OnlineShop_Framework_ICart */ protected function getCart($cartName = 'cart') { // init $manager = OnlineShop_Framework_Factory::getInstance()->getCartManager(); $cart = null; // search for the cart foreach ($manager->getCarts() as $current) { if ($current->getName() === $cartName) { $cart = $current; break; } } // create new cart if not exists if (!$cart) { $cartId = $manager->createCart(array('name' => $cartName)); $cart = $manager->getCart($cartId); } // done :-) return $cart; }
public function init() { parent::init(); // enable layout only if its a normal request if ($this->getRequest()->isXmlHttpRequest() === false) { $this->enableLayout(); $this->setLayout('back-office'); } // sprache setzen $language = $this->getUser() ? $this->getUser()->getLanguage() : 'en'; Zend_Registry::set("Zend_Locale", new Zend_Locale($language)); $this->language = $language; $this->view->language = $language; $this->initTranslation(); // enable inherited values Object_Abstract::setGetInheritedValues(true); Object_Localizedfield::setGetFallbackValues(true); // init $this->orderManager = OnlineShop_Framework_Factory::getInstance()->getOrderManager(); }
public function tenantSwitchesAction() { $this->enableLayout(); $environment = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); if ($this->getParam("change-checkout-tenant")) { $checkoutTenant = $this->getParam("change-checkout-tenant"); $checkoutTenant = $checkoutTenant == "default" ? "" : $checkoutTenant; $environment->setCurrentCheckoutTenant(strip_tags($checkoutTenant)); $environment->save(); } if ($this->getParam("change-assortment-tenant")) { $assortmentTenant = $this->getParam("change-assortment-tenant"); $assortmentTenant = $assortmentTenant == "default" ? "" : $assortmentTenant; $environment->setCurrentAssortmentTenant(strip_tags($assortmentTenant)); $environment->save(); } $this->view->checkoutTenants = array("default", "noShipping", "expensiveShipping", "paypal", "datatrans", "otherFolder"); $this->view->currentCheckoutTenant = $environment->getCurrentCheckoutTenant() ? $environment->getCurrentCheckoutTenant() : "default"; $this->view->assortmentTenants = array("default", "OptimizedMysql"); $this->view->currentAssortmentTenant = $environment->getCurrentAssortmentTenant() ? $environment->getCurrentAssortmentTenant() : "default"; }
public function testAction() { // $t = new OnlineShop_Framework_AbstractProduct(); // p_r($t); $x = OnlineShop_Framework_Factory::getInstance(); // p_r($x); $e = $x->getEnvironment(); $e->setCurrentUserId(-1); p_r($e); // p_r($e->getAllCustomItems()); $cm = $x->getCartManager(); // $key = $cm->createCart(array("name" => "mycart")); $cm->addToCart(\Pimcore\Model\Object\Concrete::getById(430), 4, 14, array()); //array("key" => 'mycart', "itemid" => 4459, "count" => 4)); // $e->setCustomItem("myitem2", "88776688"); // $e->save(); $e = $x->getEnvironment(); p_r($e); $x->saveState(); // $p = new OnlineShop_Plugin(); // p_r($p); die("meins"); }
public function cart2Action() { // init $manager = OnlineShop_Framework_Factory::getInstance()->getCartManager(); $cart = $manager->getCartByName("cart"); p_r($cart->getItems()); p_r($cart->checkoutData); die("done"); }
/** * cart rule test */ public function testCartAction() { $cart = OnlineShop_Framework_Factory::getInstance()->getCartManager()->createCart(array('name' => 'pricingTest')); $cart = OnlineShop_Framework_Factory::getInstance()->getCartManager()->getCart(2); $pricingManager = OnlineShop_Framework_Factory::getInstance()->getPricingManager(); $pricingManager->applyCartRules($cart); exit; }
/** * @param OnlineShop_OfferTool_AbstractOfferToolProduct $product * @param int $amount * @return OnlineShop_OfferTool_AbstractOfferItem */ public function addCustomItemFromProduct(OnlineShop_OfferTool_AbstractOfferToolProduct $product, $amount = 1) { $item = $this->getCustomItemByProduct($product); if (empty($item)) { $service = OnlineShop_Framework_Factory::getInstance()->getOfferToolService(); $item = $service->getNewOfferItemObject(); $item->setParent($this); $item->setPublished(true); $item->setCartItemKey($product->getId()); $item->setKey("custom_" . $product->getId()); $item->setAmount($amount); $item->setProduct($product); if ($product) { $item->setProductName($product->getOSName()); $item->setProductNumber($product->getOSProductNumber()); } $price = 0; if ($product->getOSPriceInfo($amount)->getTotalPrice()) { $price = $product->getOSPriceInfo($amount)->getTotalPrice()->getAmount(); } $item->setOriginalTotalPrice($price); $item->setFinalTotalPrice($price); } else { $item->setAmount($item->getAmount() + $amount); $price = 0; if ($product->getOSPriceInfo($item->getAmount())->getTotalPrice()) { $price = $product->getOSPriceInfo($item->getAmount())->getTotalPrice()->getAmount(); } $item->setOriginalTotalPrice($price); $item->setFinalTotalPrice($price); } $item->save(); $items = $this->getCustomItems(); $items[] = $item; $this->setCustomItems($items); $this->save(); return $item; }
protected function setCurrentCustomer(OnlineShop_OfferTool_AbstractOffer $offer) { $env = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); if (@class_exists("Object_Customer")) { $customer = \Pimcore\Model\Object\Customer::getById($env->getCurrentUserId()); $offer->setCustomer($customer); } return $offer; }
/** * Runs processUpdateIndexQueue for given tenants or for all tenants * * @param null $tenants * @param int $maxRounds - max rounds after process returns. null for infinite run until no work is left * @param string $loggername * @throws OnlineShop_Framework_Exception_InvalidConfigException */ public static function processUpdateIndexQueue($tenants = null, $maxRounds = null, $loggername = "indexupdater") { if ($tenants == null) { $tenants = OnlineShop_Framework_Factory::getInstance()->getAllTenants(); } if (!is_array($tenants)) { $tenants = array($tenants); } foreach ($tenants as $tenant) { self::log($loggername, "========================="); self::log($loggername, "Processing update index elements for tenant: " . $tenant); self::log($loggername, "========================="); $env = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); $env->setCurrentAssortmentTenant($tenant); $indexService = OnlineShop_Framework_Factory::getInstance()->getIndexService(); $worker = $indexService->getCurrentTenantWorker(); if ($worker instanceof OnlineShop_Framework_IndexService_Tenant_IBatchProcessingWorker) { $result = true; $round = 0; while ($result) { $round++; self::log($loggername, "Starting round: " . $round); $result = $worker->processUpdateIndexQueue(); self::log($loggername, "processed update index elements: " . $result); Pimcore::collectGarbage(); if ($maxRounds && $maxRounds == $round) { self::log($loggername, "skipping process after {$round} rounds."); return; } } } } }
/** * */ protected function initSavedCarts() { $env = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); $classname = $this->getCartClassName(); $carts = $classname::getAllCartsForUser($env->getCurrentUserId()); if (empty($carts)) { $this->carts = array(); } else { foreach ($carts as $c) { /* @var OnlineShop_Framework_ICart $c */ $this->carts[$c->getId()] = $c; } } }
/** * returns instance of availability system implementation based on result of getAvailabilitySystemName() * * @return OnlineShop_Framework_IAvailabilitySystem */ public function getAvailabilitySystemImplementation() { return OnlineShop_Framework_Factory::getInstance()->getAvailabilitySystem($this->getAvailabilitySystemName()); }
/** * returns default currency based on environment settings * * @return Zend_Currency */ protected function getDefaultCurrency() { return new Zend_Currency(OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrencyLocale()); }
/** * @param mixed $response * * @return OnlineShop_Framework_Payment_IStatus * @throws Exception */ public function handleResponse($response) { // check required fields $required = ['responseFingerprintOrder' => null, 'responseFingerprint' => null]; $authorizedData = ['orderNumber' => null, 'language' => null, 'amount' => null, 'currency' => null]; // check fields $check = array_intersect_key($response, $required); if (count($required) != count($check)) { throw new Exception(sprintf('required fields are missing! required: %s', implode(', ', array_keys(array_diff_key($required, $authorizedData))))); } // check fingerprint $fields = explode(',', $response['responseFingerprintOrder']); $fingerprint = ''; foreach ($fields as $field) { $fingerprint .= $field == 'secret' ? $this->secret : $response[$field]; } $fingerprint = md5($fingerprint); if ($response["paymentState"] !== "FAILURE" && $fingerprint != $response['responseFingerprint']) { // fingerprint is wrong, ignore this response throw new Exception('fingerprint is invalid'); } // handle $authorizedData = array_intersect_key($response, $authorizedData); $this->setAuthorizedData($authorizedData); // restore price object for payment status $price = new OnlineShop_Framework_Impl_Price($authorizedData['amount'], new Zend_Currency($authorizedData['currency'], OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrencyLocale())); return new OnlineShop_Framework_Impl_Payment_Status($response['orderIdent'], $response['orderNumber'], $response['avsResponseMessage'], $response['orderNumber'] !== NULL && $response['paymentState'] == 'SUCCESS' ? OnlineShop_Framework_Payment_IStatus::STATUS_AUTHORIZED : OnlineShop_Framework_Payment_IStatus::STATUS_CANCELLED, ['qpay_amount' => (string) $price, 'qpay_paymentType' => $response['paymentType'], 'qpay_paymentState' => $response['paymentState'], 'qpay_response' => print_r($response, true)]); }
/** * @param Object_Customer $user * * @return bool */ protected function loginCustomer(Object_Customer $user) { /* @var Object_User $user */ $auth = Zend_Auth::getInstance(); $auth->getStorage()->write($user->getId()); // init ecommerce framework $env = OnlineShop_Framework_Factory::getInstance()->getEnvironment(); $env->setCurrentUserId($user->getId()); $env->save(); // $analyticsTracker = new DataAnalyticsFramework_DemoApi(); // $analyticsTracker->trackLogin($user); return true; }
/** * @param OnlineShop_Framework_IPrice $currentSubTotal * @param OnlineShop_Framework_ICart $cart * * @return OnlineShop_Framework_IModificatedPrice */ public function modify(OnlineShop_Framework_IPrice $currentSubTotal, OnlineShop_Framework_ICart $cart) { return new OnlineShop_Framework_Impl_ModificatedPrice($this->getCharge(), new Zend_Currency(OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrencyLocale())); }
/** * Removes a token from cart and releases token reservation. * * @param string $code * * @throws OnlineShop_Framework_Exception_InvalidConfigException * @throws Exception * * @return bool */ public function removeVoucherToken($code) { $service = OnlineShop_Framework_Factory::getInstance()->getVoucherService(); $key = array_search($code, $this->getVoucherTokenCodes()); if ($key !== false) { if ($service->releaseToken($code, $this)) { unset($this->checkoutData[$key]); $this->save(); return true; } } else { throw new OnlineShop_Framework_Exception_VoucherServiceException("No Token with code " . $code . " in this cart.", 7); } }
public function __construct() { $this->getResource()->setCartClass(OnlineShop_Framework_Factory::getInstance()->getCartManager()->getCartClassName()); }
public function searchAction() { $values = array(); $productList = OnlineShop_Framework_Factory::getInstance()->getIndexService()->getProductListForCurrentTenant(); $productList->setVariantMode(OnlineShop_Framework_IProductList::VARIANT_MODE_INCLUDE_PARENT_OBJECT); if ($this->getParam("term")) { //$productList->addQueryCondition($this->getParam("term")); foreach (explode(" ", $this->getParam("term")) as $term) { $productList->addQueryCondition($term, "search"); } } if ($this->getParam("showResultPage")) { $params = $this->getAllParams(); if (empty($filterDefinition)) { $filterDefinition = Pimcore_Config::getWebsiteConfig()->searchFilterdefinition; } $this->view->filterDefinitionObject = $filterDefinition; // create and init filter service $filterService = OnlineShop_Framework_Factory::getInstance()->getFilterService($this->view); OnlineShop_Framework_FilterService_Helper::setupProductList($filterDefinition, $productList, $params, $this->view, $filterService, true); $this->view->filterService = $filterService; $this->view->products = $productList; // init pagination $paginator = Zend_Paginator::factory($productList); $paginator->setCurrentPageNumber($this->getParam('page')); $paginator->setItemCountPerPage($filterDefinition->getPageLimit()); $paginator->setPageRange(10); $this->view->paginator = $paginator; // print page with layout or only the list for ajax requests if ($this->getRequest()->isXmlHttpRequest() === false) { $this->enableLayout(); } else { // infinity scrolling? if ($this->getParam('infinity')) { $this->renderScript('/shop/list/products.php'); } } } else { $productList->setLimit(10); foreach ($productList as $p) { $firstSizeVariants = $p->getColorVariants(true); if (count($firstSizeVariants) == 0) { // keine varianten verfügbar $linkProduct = $p; } else { $linkProduct = $firstSizeVariants[0]; } $values[] = array("id" => $p->getId(), "value" => $p->getName(), "label" => $p->getName(), "url" => $linkProduct->getShopDetailLink($this->view)); } $this->_helper->json($values); } }
?> </th> <th width="80"><?php echo $this->translate('online-shop.back-office.order.order-items'); ?> </th> <th></th> <th width="100"><?php echo $this->translate('online-shop.back-office.order.price.total'); ?> </th> </tr> </thead> <tbody> <?php $totalSum = new Zend_Currency(OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrencyLocale()); foreach ($paginator as $item) { /* @var \OnlineShop\Framework\OrderManager\IOrderListItem $item */ $totalSum->add($item->getTotalPrice()); ?> <tr> <td> <?php $urlDetail = $this->url(['action' => 'detail', 'controller' => 'admin-order', 'module' => 'OnlineShop', 'id' => $item->getOrderId()], null, true); ?> <a href="<?php echo $urlDetail; ?> "><?php echo $item->getOrderNumber(); ?>
/** * @param string $wishlistName * * @return OnlineShop_Framework_ICart */ protected function getWishlist($wishlistName = 'wishlist') { $manager = OnlineShop_Framework_Factory::getInstance()->getCartManager(); $wishlist = null; // search for the wishlist foreach ($manager->getCarts() as $cart) { if ($cart->getName() === $wishlistName) { $wishlist = $cart; break; } } // create new wishlist if not exists if (!$wishlist) { $wishlistId = $manager->createCart(array('name' => $wishlistName)); $wishlist = $manager->getCart($wishlistId); } // done :-) return $wishlist; }