Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function get(Shop $shop, $groupIds)
 {
     $context = $this->contextService->createShopContext($shop->getId(), ContextService::FALLBACK_CUSTOMER_GROUP);
     $result = [];
     $query = $this->getQuery($context);
     foreach ($groupIds as $groupId) {
         $query->setParameter(':id', $groupId);
         $data = $query->execute()->fetchAll(\PDO::FETCH_ASSOC);
         $result[$groupId] = $this->hydrateGroup($data);
     }
     return $result;
 }
 /**
  * @param int $shopId
  * @param string[] $customerGroups
  * @param int[] $currencies
  * @return array
  */
 private function getContexts($shopId, $customerGroups, $currencies)
 {
     $contexts = [];
     foreach ($customerGroups as $customerGroup) {
         foreach ($currencies as $currency) {
             $contexts[] = $this->contextService->createProductContext($shopId, $currency, $customerGroup);
         }
     }
     return $contexts;
 }
 /**
  * Helper function to read the landing pages urls
  *
  * @return array
  */
 private function readLandingPageUrls()
 {
     $categoryId = $this->contextService->getShopContext()->getShop()->getCategory()->getId();
     $emotionRepository = $this->em->getRepository('Shopware\\Models\\Emotion\\Emotion');
     $builder = $emotionRepository->getCampaignsByCategoryId($categoryId);
     $campaigns = $builder->getQuery()->getArrayResult();
     foreach ($campaigns as &$campaign) {
         $campaign['show'] = $this->filterCampaign($campaign[0]['validFrom'], $campaign[0]['validTo']);
         $campaign['urlParams'] = array('sViewport' => 'campaign', 'emotionId' => $campaign[0]['id'], 'sCategory' => $campaign['categoryId']);
     }
     return $campaigns;
 }
 /**
  * Following events are deprecated and only implemented for backward compatibility to shopware 4
  * Removed with shopware 5.1
  *
  * @param array $product
  * @param \sArticles $module
  * @return array|mixed
  */
 public function fireArticleByIdEvents(array $product, \sArticles $module)
 {
     $getArticle = $product;
     $context = $this->contextService->getShopContext();
     if ($getArticle["pricegroupActive"]) {
         $getArticle["priceBeforePriceGroup"] = $getArticle["price"];
         $getArticle["price"] = $this->eventManager->filter('sArticles::sGetPricegroupDiscount::replace', $getArticle["price"], array('subject' => $module, 'customergroup' => $context->getCurrentCustomerGroup()->getKey(), 'groupID' => $getArticle["pricegroupID"], 'listprice' => $getArticle["price"], 'quantity' => 1, 'doMatrix' => false));
         $getArticle["price"] = $this->eventManager->filter('sArticles::sGetPricegroupDiscount::after', $getArticle["price"], array('subject' => $module, 'customergroup' => $context->getCurrentCustomerGroup()->getKey(), 'groupID' => $getArticle["pricegroupID"], 'listprice' => $getArticle["price"], 'quantity' => 1, 'doMatrix' => false));
         $getArticle["sBlockPrices"] = $this->eventManager->filter('sArticles::sGetPricegroupDiscount::replace', $getArticle["sBlockPrices"], array('subject' => $module, 'customergroup' => $context->getCurrentCustomerGroup()->getKey(), 'groupID' => $getArticle["pricegroupID"], 'listprice' => $getArticle["price"], 'quantity' => 1, 'doMatrix' => true));
         $getArticle["sBlockPrices"] = $this->eventManager->filter('sArticles::sGetPricegroupDiscount::after', $getArticle["sBlockPrices"], array('subject' => $module, 'customergroup' => $context->getCurrentCustomerGroup()->getKey(), 'groupID' => $getArticle["pricegroupID"], 'listprice' => $getArticle["price"], 'quantity' => 1, 'doMatrix' => true));
     } else {
         foreach ($getArticle["sBlockPrices"] as &$blockPrice) {
             $blockPrice["price"] = $this->eventManager->filter('sArticles::sCalculatingPrice::replace', $blockPrice["price"], array('subject' => $module, 'price' => $blockPrice["price"], 'tax' => $getArticle["tax"], 'taxId' => $getArticle["taxID"], 'article' => $getArticle));
             $blockPrice["price"] = $this->eventManager->filter('sArticles::sCalculatingPrice::after', $blockPrice["price"], array('subject' => $module, 'price' => $blockPrice["price"], 'tax' => $getArticle["tax"], 'taxId' => $getArticle["taxID"], 'article' => $getArticle));
             if (!$blockPrice['pseudoprice']) {
                 continue;
             }
             $blockPrice["pseudoprice"] = $this->eventManager->filter('sArticles::sCalculatingPrice::replace', $blockPrice["pseudoprice"], array('subject' => $module, 'price' => $blockPrice["pseudoprice"], 'tax' => $getArticle["tax"], 'taxId' => $getArticle["taxID"], 'article' => $getArticle));
             $blockPrice["pseudoprice"] = $this->eventManager->filter('sArticles::sCalculatingPrice::after', $blockPrice["pseudoprice"], array('subject' => $module, 'price' => $blockPrice["pseudoprice"], 'tax' => $getArticle["tax"], 'taxId' => $getArticle["taxID"], 'article' => $getArticle));
         }
     }
     $getArticle = Enlight()->Events()->filter('Shopware_Modules_Articles_GetArticleById_FilterArticle', $getArticle, array('subject' => $module, 'id' => $product['articleID'], 'customergroup' => $context->getCurrentCustomerGroup()->getKey()));
     if ($getArticle["unitID"]) {
         $getArticle["sUnit"] = $this->eventManager->filter('sArticles::sGetUnit::replace', $getArticle["sUnit"], array('subject' => $module, 'id' => $getArticle["unitID"]));
         $getArticle["sUnit"] = $this->eventManager->filter('sArticles::sGetUnit::after', $getArticle["sUnit"], array('subject' => $module, 'id' => $getArticle["unitID"]));
     }
     // Get cheapest price
     $getArticle["priceStartingFrom"] = $this->eventManager->filter('sArticles::sGetCheapestPrice::replace', $getArticle["priceStartingFrom"], array('subject' => $module, 'article' => $getArticle["articleID"], 'group' => $getArticle["pricegroup"], 'pricegroup' => $getArticle["pricegroupID"], 'usepricegroups' => $getArticle["pricegroupActive"]));
     // Get cheapest price
     $getArticle["priceStartingFrom"] = $this->eventManager->filter('sArticles::sGetCheapestPrice::after', $getArticle["priceStartingFrom"], array('subject' => $module, 'article' => $getArticle["articleID"], 'group' => $getArticle["pricegroup"], 'pricegroup' => $getArticle["pricegroupID"], 'usepricegroups' => $getArticle["pricegroupActive"]));
     if ($getArticle["price"]) {
         $getArticle["price"] = $this->eventManager->filter('sArticles::sCalculatingPrice::replace', $getArticle["price"], array('subject' => $module, 'price' => $getArticle["price"], 'tax' => $getArticle["tax"], 'taxId' => $getArticle["taxID"], 'article' => $getArticle));
         $getArticle["price"] = $this->eventManager->filter('sArticles::sCalculatingPrice::after', $getArticle["price"], array('subject' => $module, 'price' => $getArticle["price"], 'tax' => $getArticle["tax"], 'taxId' => $getArticle["taxID"], 'article' => $getArticle));
     }
     $getArticle["image"] = $this->eventManager->filter('sArticles::sGetArticlePictures::replace', $getArticle["image"], array('subject' => $module, 'sArticleID' => $getArticle["articleID"], 'onlyCover' => true, 'pictureSize' => 4, 'ordernumber' => $getArticle['ordernumber']));
     $getArticle["image"] = $this->eventManager->filter('sArticles::sGetArticlePictures::after', $getArticle["image"], array('subject' => $module, 'sArticleID' => $getArticle["articleID"], 'onlyCover' => true, 'pictureSize' => 4, 'ordernumber' => $getArticle['ordernumber']));
     $getArticle["images"] = $this->eventManager->filter('sArticles::sGetArticlePictures::replace', $getArticle["images"], array('subject' => $module, 'sArticleID' => $getArticle["articleID"], 'onlyCover' => false, 'pictureSize' => 0, 'ordernumber' => $getArticle['ordernumber']));
     $getArticle["images"] = $this->eventManager->filter('sArticles::sGetArticlePictures::after', $getArticle["images"], array('subject' => $module, 'sArticleID' => $getArticle["articleID"], 'onlyCover' => false, 'pictureSize' => 0, 'ordernumber' => $getArticle['ordernumber']));
     $getArticle["sVoteAverange"] = $this->eventManager->filter('sArticles::sGetArticlesAverangeVote::replace', $getArticle["sVoteAverange"], array('subject' => $module, 'article' => $getArticle["articleID"]));
     $getArticle["sVoteAverange"] = $this->eventManager->filter('sArticles::sGetArticlesAverangeVote::after', $getArticle["sVoteAverange"], array('subject' => $module, 'article' => $getArticle["articleID"]));
     $getArticle["sVoteComments"] = $this->eventManager->filter('sArticles::sGetArticlesVotes::replace', $getArticle["sVoteComments"], array('subject' => $module, 'article' => $getArticle["articleID"]));
     $getArticle["sVoteComments"] = $this->eventManager->filter('sArticles::sGetArticlesVotes::after', $getArticle["sVoteComments"], array('subject' => $module, 'article' => $getArticle["articleID"]));
     if (!empty($getArticle["filtergroupID"]) && $this->displayFiltersOnArticleDetailPage()) {
         $getArticle["sProperties"] = $this->eventManager->filter('sArticles::sGetArticleProperties::replace', $getArticle["sProperties"], array('subject' => $module, 'articleId' => $getArticle["articleID"], 'filterGroupId' => $getArticle["filtergroupID"]));
         $getArticle["sProperties"] = $this->eventManager->filter('sArticles::sGetArticleProperties::after', $getArticle["sProperties"], array('subject' => $module, 'articleId' => $getArticle["articleID"], 'filterGroupId' => $getArticle["filtergroupID"]));
     }
     $getArticle = Enlight()->Events()->filter('Shopware_Modules_Articles_GetArticleById_FilterResult', $getArticle, array('subject' => $module, 'id' => $getArticle["articleID"], 'isBlog' => false, 'customergroup' => $context->getCurrentCustomerGroup()->getKey()));
     return $getArticle;
 }
Beispiel #5
0
 /**
  * Creates different links for the product like `add to basket`, `add to note`, `view detail page`, ...
  *
  * @param StoreFrontBundle\Struct\ListProduct $product
  * @param null $categoryId
  * @return array
  */
 private function getLinksOfProduct(StoreFrontBundle\Struct\ListProduct $product, $categoryId = null)
 {
     $baseFile = $this->config->get('baseFile');
     $context = $this->contextService->getShopContext();
     $detail = $baseFile . "?sViewport=detail&sArticle=" . $product->getId();
     if ($categoryId) {
         $detail .= '&sCategory=' . $categoryId;
     }
     $rewrite = Shopware()->Modules()->Core()->sRewriteLink($detail, $product->getName());
     $basket = $baseFile . "?sViewport=basket&sAdd=" . $product->getNumber();
     $note = $baseFile . "?sViewport=note&sAdd=" . $product->getNumber();
     $friend = $baseFile . "?sViewport=tellafriend&sDetails=" . $product->getId();
     $pdf = $baseFile . "?sViewport=detail&sDetails=" . $product->getId() . "&sLanguage=" . $context->getShop()->getId() . "&sPDF=1";
     return array('linkBasket' => $basket, 'linkDetails' => $detail, 'linkDetailsRewrited' => $rewrite, 'linkNote' => $note, 'linkTellAFriend' => $friend, 'linkPDF' => $pdf);
 }
 /**
  * Returns all filterable properties depending on the given articles
  *
  * @param  array $articles
  * @return array
  */
 public function sGetComparisonProperties($articles)
 {
     $shopContext = $this->contextService->getShopContext();
     $properties = [];
     foreach ($articles as $article) {
         //get all properties in the right order
         $sql = "SELECT\n                      options.id,\n                      options.name,\n                      translation.objectdata as translation,\n                      translationFallback.objectdata as translationFallback\n\n                    FROM s_filter_options as options\n                    LEFT JOIN s_filter_relations as relations ON relations.optionId = options.id\n                    LEFT JOIN s_filter as filter ON filter.id = relations.groupID\n\n                    LEFT JOIN s_core_translations AS translation\n                    ON translation.objecttype='propertyoption'\n                    AND translation.objectkey=options.id\n                    AND translation.objectlanguage=:shopId\n\n                    LEFT JOIN s_core_translations AS translationFallback\n                    ON translationFallback.objecttype='propertyoption'\n                    AND translationFallback.objectkey=options.id\n                    AND translationFallback.objectlanguage=:fallbackId\n\n                    WHERE relations.groupID = :groupId\n                    AND filter.comparable = 1\n                    ORDER BY relations.position ASC";
         $articleProperties = $this->db->fetchAll($sql, ['groupId' => $article["filtergroupID"], 'shopId' => $shopContext->getShop()->getId(), 'fallbackId' => $shopContext->getShop()->getFallbackId()]);
         foreach ($articleProperties as $articleProperty) {
             if (!in_array($articleProperty['id'], array_keys($properties))) {
                 //the key is not part of the array so add it to the end
                 $properties[$articleProperty['id']] = $this->extractPropertyTranslation($articleProperty);
             }
         }
     }
     return $properties;
 }
Beispiel #7
0
 /**
  * Get article data for sAddArticle
  *
  * @param int $id Article ordernumber
  * @return array|false Article data, or false if none found
  */
 private function getArticleForAddArticle($id)
 {
     $sql = "\n            SELECT s_articles.id AS articleID, s_articles.main_detail_id, name AS articleName, taxID,\n              additionaltext, s_articles_details.shippingfree, laststock, instock,\n              s_articles_details.id as articledetailsID, ordernumber,\n              s_articles.configurator_set_id\n            FROM s_articles, s_articles_details\n            WHERE s_articles_details.ordernumber = ?\n            AND s_articles_details.articleID = s_articles.id\n            AND s_articles.active = 1\n            AND (\n                SELECT articleID\n                FROM s_articles_avoid_customergroups\n                WHERE articleID = s_articles.id AND customergroupID = ?\n            ) IS NULL\n        ";
     $article = $this->db->fetchRow($sql, array($id, $this->sSYSTEM->sUSERGROUPDATA["id"]));
     $article = $this->eventManager->filter('Shopware_Modules_Basket_getArticleForAddArticle_FilterArticle', $article, array("id" => $id, 'subject' => $this, "partner" => $this->sSYSTEM->_SESSION["sPartner"]));
     if (!$article) {
         return false;
     }
     $article = $this->moduleManager->Articles()->sGetTranslation($article, $article['articleID'], "article");
     $article = $this->moduleManager->Articles()->sGetTranslation($article, $article['articledetailsID'], "variant");
     if ($article['configurator_set_id'] > 0) {
         $context = $this->contextService->getProductContext();
         $product = Shopware()->Container()->get('shopware_storefront.list_product_service')->get($article['ordernumber'], $context);
         $product = $this->additionalTextService->buildAdditionalText($product, $context);
         $article['additionaltext'] = $product->getAdditional();
     }
     return $article;
 }
Beispiel #8
0
 /**
  * send order confirmation mail
  * @access public
  */
 public function sendMail($variables)
 {
     $variables = $this->eventManager->filter('Shopware_Modules_Order_SendMail_FilterVariables', $variables, array('subject' => $this));
     $shopContext = $this->contextService->getShopContext();
     $context = array('sOrderDetails' => $variables["sOrderDetails"], 'billingaddress' => $variables["billingaddress"], 'shippingaddress' => $variables["shippingaddress"], 'additional' => $variables["additional"], 'sTaxRates' => $variables["sTaxRates"], 'sShippingCosts' => $variables["sShippingCosts"], 'sAmount' => $variables["sAmount"], 'sAmountNet' => $variables["sAmountNet"], 'sOrderNumber' => $variables["ordernumber"], 'sOrderDay' => $variables["sOrderDay"], 'sOrderTime' => $variables["sOrderTime"], 'sComment' => $variables["sComment"], 'attributes' => $variables["attributes"], 'sCurrency' => $this->sSYSTEM->sCurrency["currency"], 'sLanguage' => $shopContext->getShop()->getId(), 'sSubShop' => $shopContext->getShop()->getId(), 'sEsd' => $variables["sEsd"], 'sNet' => $this->sNet);
     // Support for individual payment means with custom-tables
     if ($variables["additional"]["payment"]["table"]) {
         $paymentTable = $this->db->fetchRow("\n                  SELECT * FROM {$variables["additional"]["payment"]["table"]}\n                  WHERE userID=?", array($variables["additional"]["user"]["id"]));
         $context["sPaymentTable"] = $paymentTable ?: array();
     } else {
         $context["sPaymentTable"] = array();
     }
     if ($variables["sDispatch"]) {
         $context['sDispatch'] = $variables["sDispatch"];
     }
     if ($variables['sBookingID']) {
         $context['sBookingID'] = $variables["sBookingID"];
     }
     $mail = null;
     if ($event = $this->eventManager->notifyUntil('Shopware_Modules_Order_SendMail_Create', array('subject' => $this, 'context' => $context, 'variables' => $variables))) {
         $mail = $event->getReturn();
     }
     if (!$mail instanceof \Zend_Mail) {
         $mail = Shopware()->TemplateMail()->createMail('sORDER', $context);
     }
     $mail->addTo($this->sUserData["additional"]["user"]["email"]);
     if (!$this->config->get("sNO_ORDER_MAIL")) {
         $mail->addBcc($this->config->get('sMAIL'));
     }
     $mail = $this->eventManager->filter('Shopware_Modules_Order_SendMail_Filter', $mail, array('subject' => $this, 'context' => $context, 'variables' => $variables));
     if (!$mail instanceof \Zend_Mail) {
         return;
     }
     $this->eventManager->notify('Shopware_Modules_Order_SendMail_BeforeSend', array('subject' => $this, 'mail' => $mail, 'context' => $context, 'variables' => $variables));
     $shouldSendMail = !(bool) $this->eventManager->notifyUntil('Shopware_Modules_Order_SendMail_Send', array('subject' => $this, 'mail' => $mail, 'context' => $context, 'variables' => $variables));
     if ($shouldSendMail && $this->config->get('sendOrderMail')) {
         $mail->send();
     }
 }
Beispiel #9
0
 /**
  * Get dispatch data for basket
  * Used internally in sAdmin::sGetPremiumShippingcosts() and sAdmin::sGetPremiumDispatches()
  *
  * @param int $countryID Country id
  * @param int $paymentID Payment mean id
  * @param int $stateId Country state id
  * @return array|false Array with dispatch data for the basket, or false if no basket
  */
 public function sGetDispatchBasket($countryID = null, $paymentID = null, $stateId = null)
 {
     $sql_select = '';
     $premiumShippingBasketSelect = $this->config->get('sPREMIUMSHIPPIUNGASKETSELECT');
     if (!empty($premiumShippingBasketSelect)) {
         $sql_select .= ', ' . $premiumShippingBasketSelect;
     }
     $calculations = $this->db->fetchPairs('SELECT id, calculation_sql
         FROM s_premium_dispatch
         WHERE active = 1 AND calculation = 3');
     if (!empty($calculations)) {
         foreach ($calculations as $dispatchID => $calculation) {
             if (empty($calculation)) {
                 $calculation = $this->db->quote($calculation);
             }
             $sql_select .= ', (' . $calculation . ') as calculation_value_' . $dispatchID;
         }
     }
     if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) {
         $amount = 'b.quantity*ROUND(CAST(b.price as DECIMAL(10,2))*(100+t.tax)/100,2)';
         $amount_net = 'b.quantity*CAST(b.price as DECIMAL(10,2))';
     } else {
         $amount = 'b.quantity*CAST(b.price as DECIMAL(10,2))';
         $amount_net = 'b.quantity*ROUND(CAST(b.price as DECIMAL(10,2))/(100+t.tax)*100,2)';
     }
     $sql = "\n            SELECT\n                MIN(d.instock>=b.quantity) as instock,\n                MIN(d.instock>=(b.quantity+d.stockmin)) as stockmin,\n                MIN(a.laststock) as laststock,\n                SUM(d.weight*b.quantity) as weight,\n                SUM(IF(a.id,b.quantity,0)) as count_article,\n                MAX(b.shippingfree) as shippingfree,\n                SUM(IF(b.modus=0,{$amount}/b.currencyFactor,0)) as amount,\n                SUM(IF(b.modus=0,{$amount_net}/b.currencyFactor,0)) as amount_net,\n                SUM(CAST(b.price as DECIMAL(10,2))*b.quantity) as amount_display,\n                MAX(d.length) as `length`,\n                MAX(d.height) as height,\n                MAX(d.width) as width,\n                u.id as userID\n                {$sql_select}\n            FROM s_order_basket b\n\n            LEFT JOIN s_articles a\n            ON b.articleID = a.id\n            AND b.modus = 0\n            AND b.esdarticle = 0\n\n            LEFT JOIN s_articles_details d\n            ON (d.ordernumber = b.ordernumber)\n            AND d.articleID = a.id\n\n            LEFT JOIN s_articles_attributes at\n            ON at.articledetailsID = d.id\n\n            LEFT JOIN s_core_tax t\n            ON t.id = a.taxID\n\n            LEFT JOIN s_user u\n            ON u.id = ?\n            AND u.active = 1\n\n            LEFT JOIN s_user_billingaddress ub\n            ON ub.userID = u.id\n\n            LEFT JOIN s_user_shippingaddress us\n            ON us.userID = u.id\n\n            WHERE b.sessionID = ?\n\n            GROUP BY b.sessionID\n        ";
     $userId = $this->session->offsetGet('sUserId');
     $sessionId = $this->session->offsetGet('sessionId');
     $basket = $this->db->fetchRow($sql, array($userId, empty($sessionId) ? session_id() : $sessionId));
     if ($basket === false) {
         return false;
     }
     $basket["max_tax"] = $this->moduleManager->Basket()->getMaxTax();
     $postPaymentId = $this->front->Request()->getPost('sPayment');
     $sessionPaymentId = $this->session->offsetGet('sPaymentID');
     if (!empty($paymentID)) {
         $paymentID = (int) $paymentID;
     } elseif (!empty($userId)) {
         $user = $this->sGetUserData();
         $paymentID = (int) $user['additional']['payment']['id'];
     } elseif (!empty($postPaymentId)) {
         $paymentID = (int) $postPaymentId;
     } elseif (!empty($sessionPaymentId)) {
         $paymentID = (int) $sessionPaymentId;
     }
     $paymentMeans = $this->sGetPaymentMeans();
     $paymentIDs = array();
     foreach ($paymentMeans as $paymentMean) {
         $paymentIDs[] = $paymentMean['id'];
     }
     if (!in_array($paymentID, $paymentIDs)) {
         $paymentID = reset($paymentIDs);
     }
     if (empty($countryID) && !empty($user['additional']['countryShipping']['id'])) {
         $countryID = (int) $user['additional']['countryShipping']['id'];
     } else {
         $countryID = (int) $countryID;
     }
     if (!empty($user['additional']['stateShipping']['id'])) {
         $stateId = $user['additional']['stateShipping']['id'];
     }
     $mainId = $this->db->fetchOne('SELECT main_id FROM s_core_shops WHERE id = ?', array((int) $this->contextService->getShopContext()->getShop()->getId()));
     // Main id is null, so we use the current shop id
     if (is_null($mainId)) {
         $mainId = (int) $this->contextService->getShopContext()->getShop()->getId();
     }
     $basket['basketStateId'] = (int) $stateId;
     $basket['countryID'] = $countryID;
     $basket['paymentID'] = $paymentID;
     $basket['customergroupID'] = (int) $this->sSYSTEM->sUSERGROUPDATA['id'];
     $basket['multishopID'] = $mainId;
     $basket['sessionID'] = $sessionId;
     return $basket;
 }
Beispiel #10
0
 /**
  * executes the current product export
  *
  * @param resource $handleResource used as a file or the stdout to fetch the smarty output
  */
 public function executeExport($handleResource)
 {
     fwrite($handleResource, $this->sSmarty->fetch('string:' . $this->sSettings['header'], $this->sFeedID));
     $context = $this->contextService->getShopContext();
     $sql = $this->sCreateSql();
     $result = $this->db->query($sql);
     if ($result === false) {
         return;
     }
     // Update db with the latest values
     $count = (int) $result->rowCount();
     $this->db->update('s_export', array('last_export' => new Zend_Date(), 'cache_refreshed' => new Zend_Date(), 'count_articles' => $count), array('id = ?' => $this->sFeedID));
     // fetches all required data to smarty
     $rows = array();
     for ($rowIndex = 1; $row = $result->fetch(); $rowIndex++) {
         if (!empty($row['group_ordernumber_2'])) {
             $row['group_ordernumber'] = $this->_decode_line($row['group_ordernumber_2']);
             $row['group_pricenet'] = explode(';', $row['group_pricenet_2']);
             $row['group_price'] = explode(';', $row['group_price_2']);
             $row['group_instock'] = explode(';', $row['group_instock_2']);
             $row['group_active'] = explode(';', $row['group_active_2']);
             unset($row['group_ordernumber_2'], $row['group_pricenet_2']);
             unset($row['group_price_2'], $row['group_instock_2'], $row['group_active_2']);
             for ($i = 1; $i <= 10; $i++) {
                 if (!empty($row['group_group' . $i])) {
                     $row['group_group' . $i] = $this->_decode_line($row['group_group' . $i]);
                 } else {
                     unset($row['group_group' . $i]);
                 }
                 if (!empty($row['group_option' . $i])) {
                     $row['group_option' . $i] = $this->_decode_line($row['group_option' . $i]);
                 } else {
                     unset($row['group_option' . $i]);
                 }
             }
             unset($row['group_additionaltext']);
         } elseif (!empty($row['group_ordernumber'])) {
             $row['group_ordernumber'] = $this->_decode_line($row['group_ordernumber']);
             $row['group_additionaltext'] = $this->_decode_line($row['group_additionaltext']);
             $row['group_pricenet'] = explode(';', $row['group_pricenet']);
             $row['group_price'] = explode(';', $row['group_price']);
             $row['group_instock'] = explode(';', $row['group_instock']);
             $row['group_active'] = explode(';', $row['group_active']);
         }
         if (!empty($row['article_translation_fallback'])) {
             $translation = $this->sMapTranslation('article', $row['article_translation_fallback']);
             if ($row['main_detail_id'] != $row['articledetailsID']) {
                 unset($translation['additionaltext']);
             }
             $row = array_merge($row, $translation);
         }
         if (!empty($row['article_translation'])) {
             $translation = $this->sMapTranslation('article', $row['article_translation']);
             if ($row['main_detail_id'] != $row['articledetailsID']) {
                 unset($translation['additionaltext']);
             }
             $row = array_merge($row, $translation);
         }
         if (!empty($row['detail_translation_fallback'])) {
             $translation = $this->sMapTranslation('detail', $row['detail_translation_fallback']);
             $row = array_merge($row, $translation);
         }
         if (!empty($row['detail_translation'])) {
             $translation = $this->sMapTranslation('detail', $row['detail_translation']);
             $row = array_merge($row, $translation);
         }
         $row['name'] = htmlspecialchars_decode($row['name']);
         $row['supplier'] = htmlspecialchars_decode($row['supplier']);
         //cast it to float to prevent the division by zero warning
         $row['purchaseunit'] = floatval($row['purchaseunit']);
         $row['referenceunit'] = floatval($row['referenceunit']);
         if (!empty($row['purchaseunit']) && !empty($row['referenceunit'])) {
             $row['referenceprice'] = Shopware()->Modules()->Articles()->calculateReferencePrice($row['price'], $row['purchaseunit'], $row['referenceunit']);
         }
         if ($row['configurator'] > 0) {
             if (empty($this->sSettings["variant_export"]) || $this->sSettings["variant_export"] == 1) {
                 $row['group_additionaltext'] = array();
                 if (!empty($row['group_ordernumber'])) {
                     foreach ($row['group_ordernumber'] as $orderNumber) {
                         $product = new StoreFrontBundle\Struct\ListProduct((int) $row['articleID'], (int) $row["articledetailsID"], $orderNumber);
                         $product->setAdditional($row['additionaltext']);
                         $product = $this->additionalTextService->buildAdditionalText($product, $context);
                         if (array_key_exists($orderNumber, $row['group_additionaltext'])) {
                             $row['group_additionaltext'][$orderNumber] = $product->getAdditional();
                         }
                         if ($orderNumber == $row['ordernumber']) {
                             $row['additionaltext'] = $product->getAdditional();
                         }
                     }
                 }
             }
             $product = new StoreFrontBundle\Struct\ListProduct((int) $row['articleID'], (int) $row["articledetailsID"], $row['ordernumber']);
             $product->setAdditional($row['additionaltext']);
             $product = $this->additionalTextService->buildAdditionalText($product, $context);
             $row['additionaltext'] = $product->getAdditional();
         }
         $rows[] = $row;
         if ($rowIndex == $count || count($rows) >= 50) {
             @set_time_limit(30);
             $this->sSmarty->assign('sArticles', $rows);
             $rows = array();
             $template = 'string:{foreach $sArticles as $sArticle}' . $this->sSettings['body'] . '{/foreach}';
             fwrite($handleResource, $this->sSmarty->fetch($template, $this->sFeedID));
         }
     }
     fwrite($handleResource, $this->sSmarty->fetch('string:' . $this->sSettings['footer'], $this->sFeedID));
     fclose($handleResource);
 }
Beispiel #11
0
 public function sMailCampaignsGetDetail($id)
 {
     $sql = "\n        SELECT * FROM s_campaigns_mailings\n        WHERE id={$id}\n        ";
     $getCampaigns = $this->db->fetchRow($sql);
     if (!$getCampaigns) {
         return false;
     } else {
         // Fetch all positions
         $sql = "\n            SELECT id, type, description, value FROM s_campaigns_containers\n            WHERE promotionID={$id}\n            ORDER BY position\n            ";
         $sql = Enlight()->Events()->filter('Shopware_Modules_Marketing_MailCampaignsGetDetail_FilterSQL', $sql, array('subject' => $this, 'id' => $id));
         $getCampaignContainers = $this->db->fetchAll($sql);
         foreach ($getCampaignContainers as $campaignKey => $campaignValue) {
             switch ($campaignValue["type"]) {
                 case "ctBanner":
                     // Query Banner
                     $getBanner = $this->db->fetchRow("\n                        SELECT image, link, linkTarget, description FROM s_campaigns_banner\n                        WHERE parentID={$campaignValue["id"]}\n                        ");
                     // Rewrite banner
                     if ($getBanner["image"]) {
                         $getBanner["image"] = $this->sSYSTEM->sPathBanner . $getBanner["image"];
                     }
                     if (!preg_match("/http/", $getBanner["link"]) && $getBanner["link"]) {
                         $getBanner["link"] = "http://" . $getBanner["link"];
                     }
                     $getCampaignContainers[$campaignKey]["description"] = $getBanner["description"];
                     $getCampaignContainers[$campaignKey]["data"] = $getBanner;
                     break;
                 case "ctLinks":
                     // Query links
                     $getLinks = $this->db->fetchAll("\n                        SELECT description, link, target FROM s_campaigns_links\n                        WHERE parentID={$campaignValue["id"]}\n                        ORDER BY position\n                        ");
                     $getCampaignContainers[$campaignKey]["data"] = $getLinks;
                     break;
                 case "ctArticles":
                     $sql = "\n                        SELECT articleordernumber, type FROM s_campaigns_articles\n                        WHERE parentID={$campaignValue["id"]}\n                        ORDER BY position\n                        ";
                     $getArticles = $this->db->fetchAll($sql);
                     unset($articleData);
                     $context = $this->contextService->getShopContext();
                     foreach ($getArticles as $article) {
                         if ($article["type"]) {
                             $category = $this->sSYSTEM->_GET["sCategory"] ?: $context->getShop()->getCategory()->getId();
                             $tmpContainer = $this->sSYSTEM->sMODULES['sArticles']->sGetPromotionById($article["type"], $category, $article['articleordernumber']);
                             if (count($tmpContainer) && isset($tmpContainer["articleName"])) {
                                 $articleData[] = $tmpContainer;
                             }
                         }
                     }
                     $getCampaignContainers[$campaignKey]["data"] = $articleData;
                     break;
                 case "ctText":
                 case "ctVoucher":
                     $getText = $this->db->fetchRow("\n                            SELECT headline, html,image,alignment,link FROM s_campaigns_html\n                            WHERE parentID={$campaignValue["id"]}\n                        ");
                     if ($getText["image"]) {
                         $getText["image"] = $this->sSYSTEM->sPathBanner . $getText["image"];
                     }
                     if (!preg_match("/http/", $getText["link"]) && $getText["link"]) {
                         $getText["link"] = "http://" . $getText["link"];
                     }
                     $getCampaignContainers[$campaignKey]["description"] = $getText["headline"];
                     $getCampaignContainers[$campaignKey]["data"] = $getText;
                     break;
             }
         }
         $getCampaigns["containers"] = $getCampaignContainers;
         return $getCampaigns;
     }
 }
Beispiel #12
0
 /**
  * Returns the category tree from the root until the category
  * with the provided id. Also loads siblings for elements in the
  * category path.
  *
  * @param int $id Id of the category to load
  * @return array Tree of categories
  */
 public function sGetCategories($id)
 {
     $pathIds = $this->getCategoryPath($id);
     $grouped = $this->getCategoryIdsWithParent($pathIds);
     $ids = array_merge($pathIds, array_keys($grouped));
     $context = $this->contextService->getShopContext();
     $categories = $this->categoryService->getList($ids, $context);
     unset($grouped[$this->baseId]);
     $tree = $this->buildTree($grouped, $this->baseId);
     $result = $this->assignCategoriesToTree($categories, $tree, $pathIds, $this->getChildrenCountOfCategories($ids));
     return $result;
 }