/**
  * @inheritdoc
  * @throws \Exception
  */
 public function update()
 {
     try {
         $this->connection->executeQuery('ALTER TABLE s_import_export_profile ADD UNIQUE (`name`);');
         $defaultProfileInstaller = new DefaultProfileInstaller($this->setupContext, $this->connection);
         $defaultProfileInstaller->install();
     } catch (DBALException $exception) {
         if (!$this->isDuplicateNameError($exception)) {
             throw $exception;
         }
         throw new DuplicateNameException($this->snippetManager->getNamespace('backend/swag_importexport/default_profiles')->get('update/duplicate_names'));
     }
 }
 /**
  * @param QueryBuilderFactory $queryBuilderFactory
  * @param \Shopware_Components_Snippet_Manager $snippetManager
  * @param QueryAliasMapper $queryAliasMapper
  */
 public function __construct(QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper)
 {
     $this->queryBuilderFactory = $queryBuilderFactory;
     $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels');
     if (!($this->fieldName = $queryAliasMapper->getShortAlias('shippingFree'))) {
         $this->fieldName = 'shippingFree';
     }
 }
 /**
  * @param Criteria $criteria
  * @param $items
  * @return ValueListFacetResult
  */
 private function createFacet(Criteria $criteria, $items)
 {
     if (!($fieldName = $this->queryAliasMapper->getShortAlias('sSupplier'))) {
         $fieldName = 'sSupplier';
     }
     $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('manufacturer', 'Manufacturer');
     return new ValueListFacetResult('manufacturer', $criteria->hasCondition('manufacturer'), $label, $items, $fieldName);
 }
 /**
  * @param ManufacturerServiceInterface $manufacturerService
  * @param QueryBuilderFactory $queryBuilderFactory
  * @param \Shopware_Components_Snippet_Manager $snippetManager
  * @param QueryAliasMapper $queryAliasMapper
  */
 public function __construct(ManufacturerServiceInterface $manufacturerService, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper)
 {
     $this->manufacturerService = $manufacturerService;
     $this->queryBuilderFactory = $queryBuilderFactory;
     $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels');
     if (!($this->fieldName = $queryAliasMapper->getShortAlias('sSupplier'))) {
         $this->fieldName = 'sSupplier';
     }
 }
 /**
  * @param Criteria $criteria
  * @return BooleanFacetResult
  */
 private function createFacet(Criteria $criteria)
 {
     $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('immediate_delivery', 'Immediate delivery');
     if (!($fieldName = $this->queryAliasMapper->getShortAlias('immediateDelivery'))) {
         $fieldName = 'immediateDelivery';
     }
     $criteriaPart = new BooleanFacetResult('immediate_delivery', $fieldName, $criteria->hasCondition('immediate_delivery'), $label);
     return $criteriaPart;
 }
Exemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function generateFacet(FacetInterface $facet, Criteria $criteria, Struct\ShopContextInterface $context)
 {
     //resets all conditions of the criteria to execute a facet query without user filters.
     $queryCriteria = clone $criteria;
     $queryCriteria->resetConditions();
     $queryCriteria->resetSorting();
     $query = $this->queryBuilderFactory->createQuery($queryCriteria, $context);
     $query->innerJoin('product', 's_articles_esd', 'esd', 'esd.articleID = product.id');
     $query->select('product.id')->setMaxResults(1);
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $total = $statement->fetch(\PDO::FETCH_COLUMN);
     //found some esd products?
     if ($total <= 0) {
         return null;
     }
     $snippetNamespace = $this->snippetManager->getNamespace('frontend/listing/facet_labels');
     return new BooleanFacetResult($facet->getName(), 'esd', $criteria->hasCondition($facet->getName()), $snippetNamespace->get('swag_search_bundle_esd_only', 'Only downloads'));
 }
Exemplo n.º 7
0
 /**
  * @param CategoryServiceInterface $categoryService
  * @param QueryBuilderFactory $queryBuilderFactory
  * @param \Shopware_Components_Snippet_Manager $snippetManager
  * @param QueryAliasMapper $queryAliasMapper
  * @param Connection $connection
  */
 public function __construct(CategoryServiceInterface $categoryService, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper, Connection $connection)
 {
     $this->categoryService = $categoryService;
     $this->queryBuilderFactory = $queryBuilderFactory;
     $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels');
     $this->connection = $connection;
     if (!($this->fieldName = $queryAliasMapper->getShortAlias('sCategory'))) {
         $this->fieldName = 'sCategory';
     }
 }
Exemplo n.º 8
0
 /**
  * @param StoreException $exception
  * @return \Exception
  */
 private function translateExceptionMessage(StoreException $exception)
 {
     $namespace = $this->snippetManager->getNamespace('backend/plugin_manager/exceptions');
     if ($namespace->offsetExists($exception->getMessage())) {
         $snippet = $namespace->get($exception->getMessage());
     } else {
         $snippet = $exception->getMessage();
     }
     $snippet .= '<br><br>Error code: ' . $exception->getSbpCode();
     return new \Exception($snippet, $exception->getCode(), $exception);
 }
Exemplo n.º 9
0
 /**
  * @param PriceHelper $priceHelper
  * @param QueryBuilderFactory $queryBuilderFactory
  * @param \Shopware_Components_Snippet_Manager $snippetManager
  * @param QueryAliasMapper $queryAliasMapper
  */
 public function __construct(PriceHelper $priceHelper, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper)
 {
     $this->priceHelper = $priceHelper;
     $this->queryBuilderFactory = $queryBuilderFactory;
     $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels');
     if (!($this->minFieldName = $queryAliasMapper->getShortAlias('priceMin'))) {
         $this->minFieldName = 'priceMin';
     }
     if (!($this->maxFieldName = $queryAliasMapper->getShortAlias('priceMax'))) {
         $this->maxFieldName = 'priceMax';
     }
 }
Exemplo n.º 10
0
 /**
  * @param Category[] $categories
  * @param int[] $active
  * @return TreeFacetResult
  */
 private function createTreeFacet($categories, $active)
 {
     $items = $this->getCategoriesOfParent($categories, null);
     $values = [];
     foreach ($items as $item) {
         $values[] = $this->createTreeItem($categories, $item, $active);
     }
     $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('category', 'Categories');
     if (!($fieldName = $this->queryAliasMapper->getShortAlias('sCategory'))) {
         $fieldName = 'sCategory';
     }
     return new TreeFacetResult('category', $fieldName, empty($active), $label, $values, [], null);
 }
Exemplo n.º 11
0
 /**
  * @param Criteria $criteria
  * @return RadioFacetResult
  */
 private function createFacet(Criteria $criteria)
 {
     $activeAverage = null;
     if ($criteria->hasCondition('vote_average')) {
         /**@var $condition VoteAverageCondition*/
         $condition = $criteria->getCondition('vote_average');
         $activeAverage = $condition->getAverage();
     }
     $values = [new ValueListItem(1, '', $activeAverage == 1), new ValueListItem(2, '', $activeAverage == 2), new ValueListItem(3, '', $activeAverage == 3), new ValueListItem(4, '', $activeAverage == 4), new ValueListItem(5, '', $activeAverage == 5)];
     $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('vote_average', 'Ranking');
     if (!($fieldName = $this->queryAliasMapper->getShortAlias('rating'))) {
         $fieldName = 'rating';
     }
     return new RadioFacetResult('vote_average', $criteria->hasCondition('vote_average'), $label, $values, $fieldName, [], 'frontend/listing/filter/facet-rating.tpl');
 }
Exemplo n.º 12
0
 /**
  * Filter voucher by article id
  *
  * @param array $voucherDetails The voucher details
  * @return array Messages for detected errors
  */
 private function filterSupplierVoucher($voucherDetails)
 {
     $sErrorMessages = array();
     $allowedSupplierId = $voucherDetails["bindtosupplier"];
     if ($allowedSupplierId) {
         $allowedBasketEntriesBySupplier = $this->db->fetchRow('SELECT s_order_basket.id
             FROM s_order_basket, s_articles, s_articles_supplier
             WHERE s_order_basket.articleID = s_articles.id
             AND s_articles.supplierID = ?
             AND s_order_basket.sessionID = ?', array($allowedSupplierId, $this->session->get('sessionId')));
         if (!$allowedBasketEntriesBySupplier) {
             $allowedSupplierName = $this->db->fetchRow('SELECT name FROM s_articles_supplier WHERE id = ?', array($allowedSupplierId));
             $sErrorMessages[] = str_replace("{sSupplier}", $allowedSupplierName["name"], $this->snippetManager->getNamespace('frontend/basket/internalMessages')->get('VoucherFailureSupplier', 'This voucher is only available for products from {sSupplier}'));
         }
     }
     return $sErrorMessages;
 }
Exemplo n.º 13
0
 /**
  * @param Criteria $criteria
  * @param float $min
  * @param float $max
  * @return RangeFacetResult
  */
 private function createFacet(Criteria $criteria, $min, $max)
 {
     $activeMin = $min;
     $activeMax = $max;
     /**@var $condition PriceCondition */
     if ($condition = $criteria->getCondition('price')) {
         $activeMin = $condition->getMinPrice();
         $activeMax = $condition->getMaxPrice();
     }
     $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('price', 'Price');
     if (!($minFieldName = $this->queryAliasMapper->getShortAlias('priceMin'))) {
         $minFieldName = 'priceMin';
     }
     if (!($maxFieldName = $this->queryAliasMapper->getShortAlias('priceMax'))) {
         $maxFieldName = 'priceMax';
     }
     return new RangeFacetResult('price', $criteria->hasCondition('price'), $label, (double) $min, (double) $max, (double) $activeMin, (double) $activeMax, $minFieldName, $maxFieldName, [], 'frontend/listing/filter/facet-currency-range.tpl');
 }
Exemplo n.º 14
0
 /**
  * Helper method for sAdmin::sGetPremiumShippingcosts()
  * Calculates payment mean surcharge
  *
  * @param $country
  * @param $payment
  * @param $currencyFactor
  * @param $dispatch
  * @param $discount_tax
  */
 private function handlePaymentMeanSurcharge($country, $payment, $currencyFactor, $dispatch, $discount_tax)
 {
     $surcharge_name = $this->snippetManager->getNamespace('backend/static/discounts_surcharges')->get('payment_surcharge_absolute', 'Surcharge for payment');
     $surcharge_ordernumber = $this->config->get('sPAYMENTSURCHARGEABSOLUTENUMBER', 'PAYMENTSURCHARGEABSOLUTENUMBER');
     $percent_ordernumber = $this->config->get('sPAYMENTSURCHARGENUMBER', "PAYMENTSURCHARGE");
     // Country surcharge
     if (!empty($payment['country_surcharge'][$country['countryiso']])) {
         $payment['surcharge'] += $payment['country_surcharge'][$country['countryiso']];
     }
     $payment['surcharge'] = round($payment['surcharge'] * $currencyFactor, 2);
     // Fixed surcharge
     if (!empty($payment['surcharge']) && (empty($dispatch) || $dispatch['surcharge_calculation'] == 3)) {
         $surcharge = round($payment['surcharge'], 2);
         $payment['surcharge'] = 0;
         if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) {
             $surcharge_net = $surcharge;
             //$tax_rate = 0;
         } else {
             $surcharge_net = round($surcharge / (100 + $discount_tax) * 100, 2);
         }
         $tax_rate = $discount_tax;
         $this->db->insert('s_order_basket', array('sessionID' => $this->session->offsetGet('sessionId'), 'articlename' => $surcharge_name, 'articleID' => 0, 'ordernumber' => $surcharge_ordernumber, 'quantity' => 1, 'price' => $surcharge, 'netprice' => $surcharge_net, 'tax_rate' => $tax_rate, 'datum' => new Zend_Date(), 'modus' => 4, 'currencyFactor' => $currencyFactor));
     }
     // Percentage surcharge
     if (!empty($payment['debit_percent']) && (empty($dispatch) || $dispatch['surcharge_calculation'] != 2)) {
         $amount = $this->db->fetchOne('SELECT SUM(quantity*price) as amount
             FROM s_order_basket
             WHERE sessionID = ? GROUP BY sessionID', array($this->session->offsetGet('sessionId')));
         $percent = round($amount / 100 * $payment['debit_percent'], 2);
         if ($percent > 0) {
             $percent_name = $this->snippetManager->getNamespace('backend/static/discounts_surcharges')->get('payment_surcharge_add');
         } else {
             $percent_name = $this->snippetManager->getNamespace('backend/static/discounts_surcharges')->get('payment_surcharge_dev');
         }
         if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) {
             $percent_net = $percent;
         } else {
             $percent_net = round($percent / (100 + $discount_tax) * 100, 2);
         }
         $tax_rate = $discount_tax;
         $this->db->insert('s_order_basket', array('sessionID' => $this->session->offsetGet('sessionId'), 'articlename' => $percent_name, 'articleID' => 0, 'ordernumber' => $percent_ordernumber, 'quantity' => 1, 'price' => $percent, 'netprice' => $percent_net, 'tax_rate' => $tax_rate, 'datum' => new Zend_Date(), 'modus' => 4, 'currencyFactor' => $currencyFactor));
     }
     return $payment;
 }
Exemplo n.º 15
0
 /**
  * Helper method for sAdmin::sNewsletterSubscription
  * Subscribes the provided email address to the newsletter group
  *
  * @param $email
  * @param $groupID
  * @return array|int
  */
 private function subscribeNewsletter($email, $groupID)
 {
     $result = $this->db->fetchAll('SELECT * FROM s_campaigns_mailaddresses WHERE email = ?', array($email));
     if ($result === false) {
         $result = array("code" => 10, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('UnknownError', 'Unknown error'));
         return $result;
     } elseif (count($result)) {
         $result = array("code" => 2, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('NewsletterFailureAlreadyRegistered', 'You already receive our newsletter'));
         return $result;
     } else {
         $customer = $this->db->fetchOne('SELECT id FROM s_user WHERE email = ? LIMIT 1', array($email));
         $result = $this->db->insert('s_campaigns_mailaddresses', array('customer' => (int) (!empty($customer)), 'groupID' => $groupID, 'email' => $email));
         if ($result === false) {
             $result = array("code" => 10, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('UnknownError', 'Unknown error'));
             return $result;
         } else {
             $result = array("code" => 3, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('NewsletterSuccess', 'Thank you for receiving our newsletter'));
             return $result;
         }
     }
 }
 /**
  * @param QueryBuilderFactory $queryBuilderFactory
  * @param \Shopware_Components_Snippet_Manager $snippetManager
  */
 public function __construct(QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager)
 {
     $this->queryBuilderFactory = $queryBuilderFactory;
     $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels');
 }
Exemplo n.º 17
0
 /**
  * Returns the snippet namespace for the passed template.
  *
  * @param Shop\Template $template
  * @return \Enlight_Components_Snippet_Namespace
  */
 private function getConfigSnippetNamespace(Shop\Template $template)
 {
     return $this->snippets->getNamespace($this->util->getSnippetNamespace($template) . 'backend/config');
 }