/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPostDispatchCheckout($args) { $action = $args->getSubject(); $request = $action->Request(); $view = $action->View(); $apiKey = $this->bootstrap->Config()->get('stripeSecretKey'); \Stripe\Stripe::setApiKey($apiKey); $token = $request->getPost('stripeToken'); if (!empty($token)) { try { $this->onStripeToken($request); } catch (\Stripe\Error\Card $e) { $eJson = $e->getJsonBody(); $error = $eJson['error']; $view->assign('sErrorMessages', [$error['message']]); if ($request->getControllerName() == 'checkout') { $action->forward('shippingPayment'); } else { $action->forward('payment'); } $request->setPost('stripeToken', null); $action->Response()->clearHeader('Location')->setHttpResponseCode(200); return; } } if (!empty($view->sPayments) && !empty($view->sUserData['additional']['user']['viisonStripeCustomerId'])) { $customerId = $view->sUserData['additional']['user']['viisonStripeCustomerId']; $customer = \Stripe\Customer::retrieve($customerId); $view->stripeSources = $this->convertCards($customer['sources']['data']); } }
/** * @param \Enlight_Controller_ActionEventArgs $args * @return bool */ public function onPostDispatchAccount($args) { $action = $args->getSubject(); $request = $action->Request(); $view = $action->View(); if ($request->getParam('ppplusRedirect')) { $values = $request->getPost(); $values['payment'] = $values['sPayment']; $values['isPost'] = true; $view->assign('sFormData', $values); } if ($request->getActionName() == 'payment') { //Fix payment description $payments = $action->View()->getAssign('sPaymentMeans'); $newDescription = $this->bootstrap->Config()->get('paypalPlusDescription', ''); $newAdditionalDescription = $this->bootstrap->Config()->get('paypalPlusAdditionalDescription', ''); if (!empty($payments)) { foreach ($payments as $key => $payment) { if ($payment['name'] == 'paypal') { $payments[$key]['description'] = $newDescription; $payments[$key]['additionaldescription'] = $payment['additionaldescription'] . $newAdditionalDescription; break; } } $view->assign('sPaymentMeans', $payments); } $user = $view->getAssign('sUserData'); if (!empty($user['additional']['payment']['name']) && $user['additional']['payment']['name'] == 'paypal') { $user['additional']['payment']['description'] = $newDescription; $user['additional']['payment']['additionaldescription'] = $newAdditionalDescription; $view->assign('sUserData', $user); } } }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPostDispatchSecureListing($args) { /** @var Listing $categoryComponent */ $categoryComponent = $this->bootstrap->get('swagcustomsort.listing_component'); if (!$categoryComponent instanceof Listing) { return; } $view = $args->getSubject()->View(); $categoryId = $view->getAssign('sCategoryContent')['id']; $showCustomSort = $categoryComponent->showCustomSortName($categoryId); $baseSort = $categoryComponent->getCategoryBaseSort($categoryId); if ($showCustomSort || $baseSort > 0) { /** @var Listing $categoryComponent */ $categoryComponent = $this->bootstrap->get('swagcustomsort.listing_component'); $showCustomSort = $categoryComponent->showCustomSortName($categoryId); $useDefaultSort = $categoryComponent->showCustomSortAsDefault($categoryId); $baseSort = $categoryComponent->getCategoryBaseSort($categoryId); if ($showCustomSort || $baseSort > 0 && $useDefaultSort) { $showCustomSortOption = true; } else { $showCustomSortOption = false; } $view->assign('showCustomSort', $showCustomSortOption); $this->extendsTemplate($view, 'frontend/listing/actions/action-sorting.tpl'); } }
/** * Extends the backend template to add the grid component for the emotion designer. * * @param Enlight_Controller_ActionEventArgs $args */ public function onPostDispatchBackendEmotion(Enlight_Controller_ActionEventArgs $args) { /** @var \Shopware_Controllers_Backend_Emotion $controller */ $controller = $args->getSubject(); $view = $controller->View(); $view->addTemplateDir($this->Path() . 'Views/'); $view->extendsTemplate('backend/emotion/swag_vimeo_element/view/detail/elements/vimeo_video.js'); }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPostDispatchBackendOrder($args) { // Add View directory $view = $args->getSubject()->View(); if ($args->getRequest()->getActionName() === 'load') { $view->extendsTemplate('backend/plugins/payment_stripe/order_detail_position_refund.js'); } }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPreDispatchPaymentPaypal($args) { $request = $args->getRequest(); /** @var \Shopware_Controllers_Frontend_PaymentPaypal $action */ $action = $args->getSubject(); if ($request->getActionName() != 'return') { return; } $paymentId = $this->session->PaypalPlusPayment; if (empty($paymentId)) { return; } $payerId = $request->getParam('PayerID'); $this->restClient->setAuthToken(); $uri = 'payments/payment/' . $paymentId; $payment = $this->restClient->get($uri, array('payer_id' => $payerId)); $statusId = $this->paypalBootstrap->Config()->get('paypalStatusId', 12); if (!empty($payment['transactions'][0]['amount']['total'])) { $ppAmount = floatval($payment['transactions'][0]['amount']['total']); $ppCurrency = floatval($payment['transactions'][0]['amount']['currency']); } else { $ppAmount = 0; $ppCurrency = ''; } $swAmount = $action->getAmount(); $swCurrency = $action->getCurrencyShortName(); if (abs($swAmount - $ppAmount) >= 0.01 || $ppCurrency != $swCurrency) { $action->redirect(array('controller' => 'checkout', 'action' => 'confirm')); return; } if ($payment['state'] == 'created') { $uri = "payments/payment/{$paymentId}/execute"; $payment = $this->restClient->create($uri, array('payer_id' => $payerId)); } if ($payment['state'] == 'approved') { if (!empty($payment['transactions'][0]['related_resources'][0]['sale']['id'])) { $transactionId = $payment['transactions'][0]['related_resources'][0]['sale']['id']; } else { $transactionId = $payment['id']; } $orderNumber = $action->saveOrder($transactionId, sha1($payment['id']), $statusId); if ($payment['payment_instruction']) { $this->saveInvoiceInstructions($orderNumber, $payment); } try { $sql = ' INSERT INTO s_order_attributes (orderID, swag_payal_express) SELECT id, 2 FROM s_order WHERE ordernumber = ? ON DUPLICATE KEY UPDATE swag_payal_express = 2 '; $action->get('db')->query($sql, array($orderNumber)); } catch (\Exception $e) { } $action->redirect(array('controller' => 'checkout', 'action' => 'finish', 'sUniqueID' => sha1($payment['id']))); } }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onExtendBackendPayment($args) { $request = $args->getRequest(); $view = $args->getSubject()->View(); if ($request->getActionName() == 'load') { $this->bootstrap->registerMyTemplateDir(); $view->extendsTemplate('backend/payment/model/paypal_attribute.js'); $view->extendsTemplate('backend/payment/view/payment/paypal_form.js'); } }
/** * @param Enlight_Controller_ActionEventArgs $args */ public function onRiskManagementBackend(Enlight_Controller_ActionEventArgs $args) { $subject = $args->getSubject(); $request = $subject->Request(); $view = $subject->View(); $view->addTemplateDir(__DIR__ . '/Views/'); if ($request->getActionName() === 'load') { $view->extendsTemplate('backend/my_risk_rule/store/risks.js'); } }
/** * @param \Enlight_Controller_ActionEventArgs $args * @return bool */ public function onSaveCookieInSession(\Enlight_Controller_ActionEventArgs $args) { $request = $args->getSubject()->Request(); $cookies = $request->getParam('cookies'); $cameFromStep2 = (bool) $request->getParam('cameFromStep2'); /** @var Session $session */ $session = $this->bootstrap->get('session'); $cookies = explode(';', $cookies); $payPalCookieName = 'paypalplus_session='; foreach ($cookies as $cookie) { if (substr($cookie, 0, strlen($payPalCookieName)) == $payPalCookieName) { $payPalCookieValue = substr($cookie, strlen($payPalCookieName)); $payPalCookieValue = urldecode($payPalCookieValue); $session->offsetSet('PaypalCookieValue', $payPalCookieValue); } } $session->offsetSet('PayPalPlusCameFromStep2', $cameFromStep2); $args->getSubject()->View()->loadTemplate(''); return true; }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPostDispatchBackendIndex($args) { $action = $args->getSubject(); $request = $action->Request(); $response = $action->Response(); $view = $action->View(); if (!$request->isDispatched() || $response->isException() || $request->getActionName() != 'index' || !$view->hasTemplate()) { return; } $this->bootstrap->registerMyTemplateDir(); $view->extendsTemplate('backend/index/paypal_header.tpl'); }
/** * @param \Enlight_Controller_ActionEventArgs $args * @return bool */ public function onPostDispatchAccount($args) { $action = $args->getSubject(); $request = $action->Request(); $view = $action->View(); if ($request->getParam('ppplusRedirect')) { $values = $request->getPost(); $values['payment'] = $values['sPayment']; $values['isPost'] = true; $view->assign('sFormData', $values); } if ($request->getActionName() !== 'index' && $request->getActionName() !== 'payment') { return false; } $newDescription = $this->bootstrap->Config()->get('paypalPlusDescription', ''); $newAdditionalDescription = $this->bootstrap->Config()->get('paypalPlusAdditionalDescription', ''); if ($request->getActionName() === 'payment') { //Fix payment description $payments = $action->View()->getAssign('sPaymentMeans'); if (empty($payments)) { return false; } foreach ($payments as $key => $payment) { if ($payment['name'] !== 'paypal') { continue; } $validator = new APIValidator($this->bootstrap->get('paypal_plus.rest_client')); //Check if paypal plus is available if (!$validator->isAPIAvailable()) { continue; } $payments[$key]['description'] = $newDescription; $payments[$key]['additionaldescription'] = $payment['additionaldescription'] . $newAdditionalDescription; $view->assign('sPaymentMeans', $payments); break; } } if ($request->getActionName() === 'index') { $user = $view->getAssign('sUserData'); if (!empty($user['additional']['payment']['name']) && $user['additional']['payment']['name'] === 'paypal') { //Check if paypal plus is available $validator = new APIValidator($this->bootstrap->get('paypal_plus.rest_client')); if (!$validator->isAPIAvailable()) { return false; } $user['additional']['payment']['description'] = $newDescription; $user['additional']['payment']['additionaldescription'] = $newAdditionalDescription; $view->assign('sUserData', $user); } } }
/** * @param \Enlight_Controller_ActionEventArgs $args * @return bool */ public function onPaymentPaypalWebhook($args) { $action = $args->getSubject(); $payment = $action->Request()->getRawBody(); $payment = json_decode($payment, true); $transactionId = null; if (empty($payment['resource']['id'])) { $message = "PayPal-Webhook"; $context = array('request.body' => $payment); $action->get('pluginlogger')->error($message, $context); } else { $transactionId = $payment['resource']['id']; } $action->forward('notify', null, null, array('txn_id' => $transactionId)); return true; }
/** * @param \Enlight_Controller_ActionEventArgs $args * @return bool */ public function onPaypalPlusRedirect($args) { $action = $args->getSubject(); $request = $action->Request(); $selectPaymentId = (int) $request->get('selectPaymentId'); $request->setPost('sPayment', $selectPaymentId); $checkData = $this->admin->sValidateStep3(); if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed'])) { $action->forward('payment', 'account', 'frontend', array('ppplusRedirect' => 1)); return true; } else { $this->admin->sUpdatePayment(); } $action->forward('confirm', 'checkout', 'frontend', array('ppplusRedirect' => 1)); return true; }
public function onPostDispatch(Enlight_Controller_ActionEventArgs $arguments) { try { $controller = $arguments->getSubject(); $request = $controller->Request(); $response = $controller->Response(); $view = $controller->View(); if (!$request->isDispatched() || $response->isException() || !$view->hasTemplate() || 'frontend' !== $request->getModuleName() || !$this->isActive()) { return; } if ('checkout' === $request->getControllerName() && 'finish' === $request->getActionName()) { $sOrderNumber = $view->getAssign('sOrderNumber'); $visitorIp = $request->getClientIp(true); $this->trackOrder($sOrderNumber, $visitorIp); } else { $this->loadWidget($view); } } catch (\Exception $exception) { } }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function convertSearch(\Enlight_Controller_ActionEventArgs $args) { /**@var $shop Shop */ $shop = $this->container->get('shop'); if ($shop->getTemplate()->getVersion() >= 3) { return; } /**@var $controller \Shopware_Controllers_Frontend_Search*/ $controller = $args->getSubject(); $request = $controller->Request(); $assign = $controller->View()->getAssign(); if (!isset($assign['facets'])) { return; } $facets = $assign['facets']; /**@var $criteria Criteria*/ $criteria = $assign['criteria']; $activeCategoryId = $this->getActiveCategoryId($shop, $criteria); $priceRanges = $this->getPriceRanges(); $priceFacetValues = null; $manufacturerFacet = null; $categoryFacet = null; foreach ($facets as $facet) { if (!$facet instanceof FacetResultInterface) { continue; } if ($facet->getFacetName() == 'price') { $priceFacetValues = $this->getPriceRangeValues($priceRanges, $facet); } elseif ($facet->getFacetName() == 'category') { $categoryFacet = $this->convertCategoryFacet($facet, $activeCategoryId); } elseif ($facet->getFacetName() == 'manufacturer') { $manufacturerFacet = $this->convertManufacturerFacet($facet); } } $result = $assign['sSearchResults']; $result = array_merge($result, array('sLastCategory' => $activeCategoryId, 'sPrices' => $priceFacetValues, 'sSuppliers' => $manufacturerFacet, 'sCategories' => $categoryFacet)); $controller->View()->assign('sSearchResults', $result); $controller->View()->assign(array('sPriceFilter' => $priceRanges, 'sLinks' => $this->getSearchLinks($request, $criteria), 'sPages' => $this->getPages($criteria, $request->getParam('sPage', 1), $result['sArticlesCount']), 'sPerPage' => array_values(explode("|", $this->container->get('config')->get('fuzzySearchSelectPerPage'))), 'sRequests' => $this->getRequestValues($criteria, $request), 'sCategoriesTree' => $this->getCategoryTree($activeCategoryId, $shop->getCategory()->getId()))); }
/** * Event listener method * * @param Enlight_Controller_ActionEventArgs $args */ public function onPostDispatch(Enlight_Controller_ActionEventArgs $args) { $request = $args->getSubject()->Request(); $view = $args->getSubject()->View(); if ($request->isXmlHttpRequest()) { return; } $config = $this->Config(); if (empty($config->tracking_code) && empty($config->conversion_code)) { return; } $view->addTemplateDir(__DIR__ . '/Views/Common'); $version = Shopware()->Shop()->getTemplate()->getVersion(); if ($version >= 3) { $view->addTemplateDir(__DIR__ . '/Views/Responsive'); } else { $view->addTemplateDir(__DIR__ . '/Views/Emotion'); $view->extendsTemplate('frontend/checkout/index_google.tpl'); if ($request->getActionName() === 'finish') { $view->extendsTemplate('frontend/checkout/finish_google.tpl'); } } if (!empty($config->conversion_code)) { $view->GoogleConversionID = $config->conversion_code; $view->GoogleConversionLanguage = Shopware()->Locale()->getLanguage(); } if (!empty($config->tracking_code)) { $view->GoogleTrackingID = $config->tracking_code; $view->GoogleAnonymizeIp = $config->anonymize_ip; $view->GoogleTrackingLibrary = $config->trackingLib; } }
/** * @param ActionEventArgs $args * @return array */ public function addAddTemplateDir($args) { $args->getSubject()->View()->addTemplateDir($this->templateDir); }
/** * Event listener method * * @param Enlight_Controller_ActionEventArgs $args */ public function onPostDispatch(Enlight_Controller_ActionEventArgs $args) { $config = $this->Config(); if (!$config->show) { return; } $view = $args->getSubject()->View(); $parent = Shopware()->Shop()->get('parentID'); $categoryId = $args->getRequest()->getParam('sCategory', $parent); $menu = $this->getAdvancedMenu($parent, $categoryId, (int) $config->levels); $view->assign('sAdvancedMenu', $menu); $view->assign('columnAmount', $config->columnAmount); $view->addTemplateDir($this->Path() . 'Views'); }
/** * @param ActionEventArgs $args */ public function onPostDispatchSecureBackendIndex(ActionEventArgs $args) { $view = $args->getSubject()->View(); $view->addTemplateDir($this->bootstrap->Path() . 'Views/'); $view->extendsTemplate('backend/custom_sort/header.tpl'); }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPostDispatchCheckout($args) { $cameFromStep2 = $this->session->offsetGet('PayPalPlusCameFromStep2'); if (!$cameFromStep2) { unset($this->session->PaypalPlusPayment); } $action = $args->getSubject(); $request = $action->Request(); $response = $action->Response(); $view = $action->View(); // Secure dispatch if (!$request->isDispatched() || $response->isException() || $response->isRedirect()) { return; } /** @var $shopContext \Shopware\Models\Shop\Shop */ $shopContext = $this->bootstrap->get('shop'); $templateVersion = $shopContext->getTemplate()->getVersion(); if ($request->getActionName() == 'finish') { $this->addInvoiceInstructionsToView($view, $templateVersion); } //Fix payment description $newDescription = $this->bootstrap->Config()->get('paypalPlusDescription', ''); $newAdditionalDescription = $this->bootstrap->Config()->get('paypalPlusAdditionalDescription', ''); $payments = $view->getAssign('sPayments'); if (!empty($payments)) { foreach ($payments as $key => $payment) { if ($payment['name'] == 'paypal') { $payments[$key]['description'] = $newDescription; $payments[$key]['additionaldescription'] = $payment['additionaldescription'] . $newAdditionalDescription; break; } } $view->assign('sPayments', $payments); } $user = $view->getAssign('sUserData'); if (!empty($user['additional']['payment']['name']) && $user['additional']['payment']['name'] == 'paypal') { $user['additional']['payment']['description'] = $newDescription; $user['additional']['payment']['additionaldescription'] = $newAdditionalDescription; $view->assign('sUserData', $user); } if (method_exists($this->paypalBootstrap, 'getPayment')) { $payPalPaymentId = $this->paypalBootstrap->getPayment()->getId(); } else { //fallback for SwagPaymentPaypal verion < 3.3.4 $payPalPaymentId = $this->paypalBootstrap->Payment()->getId(); } $view->assign('PayPalPaymentId', $payPalPaymentId); $allowedActions = array('confirm', 'shippingPayment', 'saveShippingPayment'); // Check action if (!in_array($request->getActionName(), $allowedActions, true)) { return; } if ($request->get('ppplusRedirect')) { $action->redirect(array('controller' => 'checkout', 'action' => 'payment', 'sAGB' => 1)); return; } // Paypal plus conditions $user = $view->getAssign('sUserData'); $countries = $this->bootstrap->Config()->get('paypalPlusCountries'); if ($countries instanceof \Enlight_Config) { $countries = $countries->toArray(); } else { $countries = (array) $countries; } if (!empty($this->session->PaypalResponse['TOKEN']) || empty($user['additional']['payment']['name']) || !in_array($user['additional']['country']['id'], $countries)) { return; } if ($this->session->offsetExists('PaypalCookieValue') && $request->getActionName() != 'shippingPayment') { setcookie('paypalplus_session', $this->session->offsetGet('PaypalCookieValue')); $view->assign('cameFromStep2', $cameFromStep2); $this->session->offsetUnset('PaypalCookieValue'); $this->session->offsetUnset('PayPalPlusCameFromStep2'); } $this->bootstrap->registerMyTemplateDir(); if ($request->getActionName() == 'shippingPayment' || !$cameFromStep2) { $this->onPaypalPlus($action); } if ($templateVersion < 3) { // emotion template $view->extendsTemplate('frontend/payment_paypal_plus/checkout.tpl'); } }
/** * When index backend module was loaded, add our snippet- and template-directory * Also extend the template * * @param \Enlight_Controller_ActionEventArgs $args */ public function onBackendIndexPostDispatch(Enlight_Controller_ActionEventArgs $args) { $args->getSubject()->View()->addTemplateDir(__DIR__ . '/Views/'); // if the controller action name equals "load" we inject our update check if ($args->getRequest()->getActionName() === 'load') { $args->getSubject()->View()->extendsTemplate('backend/index/view/swag_update_menu.js'); } }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function onPreDispatchPaymentPaypal(\Enlight_Controller_ActionEventArgs $args) { $request = $args->getRequest(); /** @var \Shopware_Controllers_Frontend_PaymentPaypal $controller */ $controller = $args->getSubject(); if ($request->getActionName() != 'return') { return; } $paymentId = $request->get('paymentId'); if (!$paymentId) { return; } $payerId = $request->getParam('PayerID'); $uri = 'payments/payment/' . $paymentId; $payment = array(); try { $payment = $this->restClient->get($uri, array('payer_id' => $payerId)); } catch (Exception $e) { $this->logException('An error occurred on getting the payment on returning from PayPal', $e); } if (!empty($payment['transactions'][0]['amount']['total'])) { $ppAmount = floatval($payment['transactions'][0]['amount']['total']); $ppCurrency = floatval($payment['transactions'][0]['amount']['currency']); } else { $ppAmount = 0; $ppCurrency = ''; } $swAmount = $controller->getAmount(); $swCurrency = $controller->getCurrencyShortName(); if (abs($swAmount - $ppAmount) >= 0.01 || $ppCurrency != $swCurrency) { $controller->redirect(array('controller' => 'checkout', 'action' => 'confirm')); return; } $paypalConfig = $this->paypalBootstrap->Config(); $orderNumber = null; if ($payment['state'] == 'created') { if ($paypalConfig->get('paypalSendInvoiceId')) { $orderNumber = $controller->saveOrder($payment['id'], sha1($payment['id'])); $params = array(array('op' => 'add', 'path' => '/transactions/0/invoice_number', 'value' => $orderNumber)); $prefix = $paypalConfig->get('paypalPrefixInvoiceId'); if ($prefix) { // Set prefixed invoice id - Remove special chars and spaces $prefix = str_replace(' ', '', $prefix); $prefix = preg_replace('/[^A-Za-z0-9\\_]/', '', $prefix); $params[0]['value'] = $prefix . $orderNumber; } $uri = 'payments/payment/' . $paymentId; try { $this->restClient->patch($uri, $params); } catch (Exception $e) { $this->logException('An error occurred on patching the order number to the payment', $e); } } $uri = "payments/payment/{$paymentId}/execute"; try { $payment = $this->restClient->create($uri, array('payer_id' => $payerId)); } catch (Exception $e) { $this->logException('An error occurred on executing the payment', $e); } } if ($payment['state'] == 'approved') { if (!empty($payment['transactions'][0]['related_resources'][0]['sale']['id'])) { $transactionId = $payment['transactions'][0]['related_resources'][0]['sale']['id']; } else { $transactionId = $payment['id']; } if (!$orderNumber) { $orderNumber = $controller->saveOrder($transactionId, sha1($payment['id'])); } else { $sql = 'UPDATE s_order SET transactionID = ? WHERE ordernumber = ?;'; $controller->get('db')->query($sql, array($transactionId, $orderNumber)); } if (!empty($payment['transactions'][0]['related_resources'][0]['sale']['state'])) { $paymentStatus = ucfirst($payment['transactions'][0]['related_resources'][0]['sale']['state']); $this->paypalBootstrap->setPaymentStatus($transactionId, $paymentStatus); } if ($payment['payment_instruction']) { $this->saveInvoiceInstructions($orderNumber, $payment); } try { $sql = ' INSERT INTO s_order_attributes (orderID, swag_payal_express) SELECT id, 2 FROM s_order WHERE ordernumber = ? ON DUPLICATE KEY UPDATE swag_payal_express = 2 '; $controller->get('db')->query($sql, array($orderNumber)); } catch (Exception $e) { } $controller->redirect(array('controller' => 'checkout', 'action' => 'finish', 'sUniqueID' => sha1($payment['id']))); } }
/** * @param \Enlight_Controller_ActionEventArgs $args */ public function convertListing(\Enlight_Controller_ActionEventArgs $args) { if (!$this->isLegacyTemplate()) { return; } /**@var $view \Enlight_View_Default */ $view = $args->getSubject()->View(); $totalCount = $view->getAssign('sNumberArticles'); $shortParameters = $view->getAssign('shortParameters') ?: []; $params = $this->getCategoryConfig($args->getSubject()->Request()); $view->assign('sPerPage', $this->createListingPerPageLinks($params)); $view->assign('categoryParams', $this->getFilteredCategoryParams($shortParameters, $params)); $pages = $this->createListingPageLinks($totalCount, $params); $view->assign('sPages', $pages); $view->assign('sNumberPages', count($pages['numbers'])); $facets = $this->convertFacets($view->getAssign('facets'), $params); $view->assign($facets); }
/** * On post dispatch we try to find affected articleIds displayed during this request * * @param \Enlight_Controller_ActionEventArgs $args */ public function onPostDispatch(\Enlight_Controller_ActionEventArgs $args) { $view = $args->getSubject()->View(); if (!$this->request->isDispatched() || $this->response->isException() || !$view->hasTemplate()) { return; } if (!$this->hasSurrogateEsiCapability($this->request)) { return; } if ($this->request->getModuleName() != 'frontend' && $this->request->getModuleName() != 'widgets') { return; } // Do not cache if shop(template) is not esi-enabled if (!Shopware()->Shop()->get('esi')) { return; } // Enable esi tag output $this->registerEsiRenderer(); $this->addSurrogateControl($this->response); $this->addContextCookie($this->request, $this->response); $this->setNoCacheCookie(); /** * Emits Shopware_Plugins_HttpCache_ShouldNotCache Event */ if (Enlight()->Events()->notifyUntil('Shopware_Plugins_HttpCache_ShouldNotCache', array('subject' => $this, 'action' => $this->action))) { return; } $this->setCacheHeaders(); }
/** * adds the templates directories which expand the customer module * * @param Enlight_Controller_ActionEventArgs $args */ public function onCustomerPostDispatchSecure(Enlight_Controller_ActionEventArgs $args) { $view = $args->getSubject()->View(); $args->getSubject()->View()->addTemplateDir($this->Path() . 'Views/'); if ($args->getRequest()->getActionName() === 'load') { $view->extendsTemplate('backend/customer/controller/create_backend_order/detail.js'); $view->extendsTemplate('backend/customer/controller/create_backend_order/main.js'); $view->extendsTemplate('backend/customer/view/create_backend_order/detail/base.js'); $view->extendsTemplate('backend/customer/view/create_backend_order/detail/additional.js'); $view->extendsTemplate('backend/customer/view/create_backend_order/detail/window.js'); } }
/** * @param \Enlight_Controller_ActionEventArgs $args * @return bool */ public function onPreRedirectToPayPal($args) { $controller = $args->getSubject(); $view = $controller->View(); $userData = $view->getAssign('sUserData'); $paymentId = $this->session->offsetGet('PaypalPlusPayment'); $payment = $userData['additional']['payment']; $this->session->sOrderVariables['sPayment'] = $payment; $this->session->sOrderVariables['sUserData']['additional']['payment'] = $payment; $requestData = array(array('op' => 'add', 'path' => '/transactions/0/item_list/shipping_address', 'value' => $this->getShippingAddress($userData))); $uri = 'payments/payment/' . $paymentId; $view->loadTemplate(''); try { $this->restClient->patch($uri, $requestData); } catch (Exception $e) { $this->logException('An error occurred on patching the address to the payment', $e); echo json_encode(array('success' => false)); return true; } echo json_encode(array('success' => true)); return true; }