示例#1
0
 /**
  * @covers sBasket::sGetBasketIds
  */
 public function testsGetBasketIds()
 {
     $randomArticles = $this->db->fetchAll('SELECT * FROM s_articles_details detail
         INNER JOIN s_articles article
           ON article.id = detail.articleID
         WHERE detail.active = 1
         ORDER BY RAND() LIMIT 2');
     $this->module->sSYSTEM->sSESSION_ID = uniqid();
     $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID);
     // Test with empty basket, empty
     $this->assertNull($this->module->sGetBasketIds());
     // Add the first article to the basket, test we get the article id
     $this->db->insert('s_order_basket', array('price' => 1, 'quantity' => 1, 'sessionID' => $this->session->get('sessionId'), 'ordernumber' => $randomArticles[0]['ordernumber'], 'articleID' => $randomArticles[0]['articleID']));
     $this->assertEquals(array($randomArticles[0]['articleID']), $this->module->sGetBasketIds());
     // Add the first article to the basket again, test we get the same result
     $this->db->insert('s_order_basket', array('price' => 1, 'quantity' => 1, 'sessionID' => $this->session->get('sessionId'), 'ordernumber' => $randomArticles[0]['ordernumber'], 'articleID' => $randomArticles[0]['articleID']));
     $this->assertEquals(array($randomArticles[0]['articleID']), $this->module->sGetBasketIds());
     // Add the second article to the basket, test we get the two ids
     $this->db->insert('s_order_basket', array('price' => 1, 'quantity' => 1, 'sessionID' => $this->session->get('sessionId'), 'ordernumber' => $randomArticles[1]['ordernumber'], 'articleID' => $randomArticles[1]['articleID']));
     $basketIds = $this->module->sGetBasketIds();
     $this->assertContains($randomArticles[0]['articleID'], $basketIds);
     $this->assertContains($randomArticles[1]['articleID'], $basketIds);
     // Housekeeping
     $this->db->delete('s_order_basket', array('sessionID = ?' => $this->session->get('sessionId')));
 }
示例#2
0
 /**
  * @return array
  */
 private function loadBasketArticles()
 {
     $sql = "\n        SELECT\n            s_order_basket.*,\n            COALESCE (NULLIF(ad.packunit, ''), mad.packunit) AS packunit,\n            a.main_detail_id AS mainDetailId,\n            ad.id AS articleDetailId,\n            ad.minpurchase,\n            a.taxID,\n            ad.instock AS instock,\n            ad.suppliernumber,\n            ad.maxpurchase,\n            ad.purchasesteps,\n            ad.purchaseunit,\n            COALESCE (ad.unitID, mad.unitID) AS unitID,\n            a.laststock,\n            ad.shippingtime,\n            ad.releasedate,\n            ad.releasedate AS sReleaseDate,\n            COALESCE (ad.ean, mad.ean) AS ean,\n            ad.stockmin,\n            s_order_basket_attributes.attribute1 as ob_attr1,\n            s_order_basket_attributes.attribute2 as ob_attr2,\n            s_order_basket_attributes.attribute3 as ob_attr3,\n            s_order_basket_attributes.attribute4 as ob_attr4,\n            s_order_basket_attributes.attribute5 as ob_attr5,\n            s_order_basket_attributes.attribute6 as ob_attr6\n        FROM s_order_basket\n        LEFT JOIN s_articles_details AS ad ON ad.ordernumber = s_order_basket.ordernumber\n        LEFT JOIN s_articles a ON (a.id = ad.articleID)\n        LEFT JOIN s_articles_details AS mad ON mad.id = a.main_detail_id\n        LEFT JOIN s_order_basket_attributes ON s_order_basket.id = s_order_basket_attributes.basketID\n        WHERE sessionID=?\n        ORDER BY id ASC, datum DESC\n        ";
     $sql = $this->eventManager->filter('Shopware_Modules_Basket_GetBasket_FilterSQL', $sql, array('subject' => $this));
     $getArticles = $this->db->fetchAll($sql, array($this->session->get('sessionId')));
     return $getArticles;
 }
示例#3
0
 /**
  * Create rewrite rules for articles
  *
  * @param string $lastUpdate
  * @param int $limit
  * @return string
  */
 public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
 {
     $routerArticleTemplate = $this->config->get('sROUTERARTICLETEMPLATE');
     if (empty($routerArticleTemplate)) {
         return $lastUpdate;
     }
     $this->db->query('UPDATE `s_articles` SET `changetime`= NOW() WHERE `changetime`=?', array('0000-00-00 00:00:00'));
     $sql = $this->getSeoArticleQuery();
     $sql = $this->db->limit($sql, $limit);
     $result = $this->db->fetchAll($sql, array(Shopware()->Shop()->get('parentID'), Shopware()->Shop()->getId(), $lastUpdate));
     $result = $this->mapArticleTranslationObjectData($result);
     $result = Shopware()->Events()->filter('Shopware_Modules_RewriteTable_sCreateRewriteTableArticles_filterArticles', $result, array('shop' => Shopware()->Shop()->getId()));
     foreach ($result as $row) {
         $this->data->assign('sArticle', $row);
         $path = $this->template->fetch('string:' . $routerArticleTemplate, $this->data);
         $path = $this->sCleanupPath($path, false);
         $orgPath = 'sViewport=detail&sArticle=' . $row['id'];
         $this->sInsertUrl($orgPath, $path);
         $lastUpdate = $row['changed'];
         $lastId = $row['id'];
     }
     if (!empty($lastId)) {
         $this->db->query('UPDATE s_articles
             SET changetime = DATE_ADD(changetime, INTERVAL 1 SECOND)
             WHERE changetime=?
             AND id > ?', array($lastUpdate, $lastId));
     }
     return $lastUpdate;
 }
示例#4
0
 /**
  * Read data with translations from database
  *
  * @return array
  */
 protected function readData()
 {
     $sql = "\n            SELECT\n              LOWER(REPLACE(e.name, '_', '')) as name,\n              IFNULL(IFNULL(v2.value, v1.value), e.value) as value,\n              LOWER(REPLACE(forms.name, '_', '')) as form\n            FROM s_core_config_elements e\n            LEFT JOIN s_core_config_values v1\n            ON v1.element_id = e.id\n            AND v1.shop_id = ?\n            LEFT JOIN s_core_config_values v2\n            ON v2.element_id = e.id\n            AND v2.shop_id = ?\n            LEFT JOIN s_core_config_forms forms\n            ON forms.id = e.form_id\n        ";
     $data = $this->_db->fetchAll($sql, array(1, isset($this->_shop) ? $this->_shop->getId() : null));
     $result = array();
     foreach ($data as $row) {
         $result[$row['name']] = unserialize($row['value']);
         // Take namespaces (form names) into account
         $result[$row['form'] . '::' . $row['name']] = unserialize($row['value']);
     }
     $result['version'] = Shopware::VERSION;
     $result['revision'] = Shopware::REVISION;
     $result['versiontext'] = Shopware::VERSION_TEXT;
     return $result;
 }
示例#5
0
 /**
  * Read data with translations from database
  *
  * @return array
  */
 protected function readData()
 {
     $sql = "\n            SELECT\n              LOWER(REPLACE(e.name, '_', '')) as name,\n              COALESCE(currentShop.value, parentShop.value, fallbackShop.value, e.value) as value,\n              LOWER(REPLACE(forms.name, '_', '')) as form,\n              currentShop.value as currentShopval,\n              parentShop.value as parentShopval,\n              fallbackShop.value as fallbackShopval\n\n            FROM s_core_config_elements e\n\n            LEFT JOIN s_core_config_values currentShop\n              ON currentShop.element_id = e.id\n              AND currentShop.shop_id = :currentShopId\n\n            LEFT JOIN s_core_config_values parentShop\n              ON parentShop.element_id = e.id\n              AND parentShop.shop_id = :parentShopId\n\n            LEFT JOIN s_core_config_values fallbackShop\n              ON fallbackShop.element_id = e.id\n              AND fallbackShop.shop_id = :fallbackShopId\n\n            LEFT JOIN s_core_config_forms forms\n              ON forms.id = e.form_id\n        ";
     $data = $this->_db->fetchAll($sql, array('fallbackShopId' => 1, 'parentShopId' => isset($this->_shop) && $this->_shop->getMain() !== null ? $this->_shop->getMain()->getId() : 1, 'currentShopId' => isset($this->_shop) ? $this->_shop->getId() : null));
     $result = array();
     foreach ($data as $row) {
         $value = !empty($row['value']) ? @unserialize($row['value']) : null;
         $result[$row['name']] = $value;
         // Take namespaces (form names) into account
         $result[$row['form'] . '::' . $row['name']] = $value;
     }
     $result['version'] = Shopware::VERSION;
     $result['revision'] = Shopware::REVISION;
     $result['versiontext'] = Shopware::VERSION_TEXT;
     return $result;
 }
 /**
  * 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;
 }
示例#7
0
 /**
  * Gets related pages for the given page
  *
  * @param array $staticPage
  * @param int|null $shopId
  * @return mixed
  */
 private function getRelatedForPage($staticPage, $shopId = null)
 {
     $andWhere = '';
     $params = array('pageId' => $staticPage['id']);
     if ($shopId) {
         $andWhere .= ' AND (p.shop_ids IS NULL OR p.shop_ids LIKE :shopId)';
         $params['shopId'] = '%|' . $shopId . '|%';
     }
     $sql = '
             SELECT p.id, p.description, p.link, p.target, p.page_title
             FROM s_cms_static p
             WHERE p.parentID = :pageId
             ' . $andWhere . '
             ORDER BY p.position
         ';
     $staticPage['subPages'] = $this->db->fetchAll($sql, $params);
     return $staticPage;
 }
示例#8
0
 private function createProperties($groupCount, $optionCount, $namePrefix = 'Test')
 {
     $this->propertyNames[] = $namePrefix;
     $this->deleteProperties($namePrefix);
     $this->db->insert('s_filter', array('name' => $namePrefix . '-Set', 'comparable' => 1));
     $data = $this->db->fetchRow("SELECT * FROM s_filter WHERE name = '" . $namePrefix . "-Set'");
     for ($i = 0; $i < $groupCount; $i++) {
         $this->db->insert('s_filter_options', array('name' => $namePrefix . '-Gruppe-' . $i, 'filterable' => 1));
         $group = $this->db->fetchRow("SELECT * FROM s_filter_options WHERE name = '" . $namePrefix . "-Gruppe-" . $i . "'");
         for ($i2 = 0; $i2 < $optionCount; $i2++) {
             $this->db->insert('s_filter_values', array('value' => $namePrefix . '-Option-' . $i . '-' . $i2, 'optionID' => $group['id']));
         }
         $group['options'] = $this->db->fetchAll("SELECT * FROM s_filter_values WHERE optionID = ?", array($group['id']));
         $data['groups'][] = $group;
         $this->db->insert('s_filter_relations', array('optionID' => $group['id'], 'groupID' => $data['id']));
     }
     return $data;
 }
 /**
  * Create CMS rewrite rules
  * Used in multiple locations
  *
  * @param int $offset
  * @param int $limit
  */
 public function sCreateRewriteTableContent($offset = null, $limit = null)
 {
     $sql = "SELECT id, description as name FROM `s_emarketing_promotion_main`";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $eMarketingPromotion = $this->db->fetchAll($sql);
     foreach ($eMarketingPromotion as $row) {
         $org_path = 'sViewport=campaign&sCampaign=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
     $sql = "SELECT id, name, ticket_typeID FROM `s_cms_support`";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $cmsSupport = $this->db->fetchAll($sql);
     foreach ($cmsSupport as $row) {
         $org_path = 'sViewport=ticket&sFid=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
     $sql = "SELECT id, description as name FROM `s_cms_static` WHERE link=''";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $cmsStatic = $this->db->fetchAll($sql);
     foreach ($cmsStatic as $row) {
         $org_path = 'sViewport=custom&sCustom=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
     $sql = "SELECT id, description as name FROM `s_cms_groups`";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $cmsGroups = $this->db->fetchAll($sql);
     foreach ($cmsGroups as $row) {
         $org_path = 'sViewport=content&sContent=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
 }
示例#10
0
 /**
  * Read a specific, static page (E.g. terms and conditions, etc.)
  *
  * @param int $staticId The page id
  * @return array|false Page data, or false if none found by given id
  */
 public function sGetStaticPage($staticId = null)
 {
     if (empty($staticId)) {
         $staticId = (int) $this->front->Request()->getQuery('sCustom', $staticId);
     }
     if (empty($staticId)) {
         return false;
     }
     // Load static page data from database
     $staticPage = $this->db->fetchRow("SELECT * FROM s_cms_static WHERE id = ?", array($staticId));
     if ($staticPage === false) {
         return false;
     }
     /**
      * Add support for sub pages
      */
     if (!empty($staticPage['parentID'])) {
         $sql = '
             SELECT p.id, p.description, p.link, p.target, IF(p.id=?, 1, 0) as active, p.page_title
             FROM s_cms_static p
             WHERE p.parentID = ?
             ORDER BY p.position
         ';
         $staticPage['siblingPages'] = $this->db->fetchAll($sql, array($staticId, $staticPage['parentID']));
         $sql = '
             SELECT p.id, p.description, p.link, p.target, p.page_title
             FROM s_cms_static p
             WHERE p.id = ?
         ';
         $staticPage['parent'] = $this->db->fetchRow($sql, array($staticPage['parentID']));
         $staticPage['parent'] = $staticPage['parent'] ?: array();
     } else {
         $sql = '
             SELECT p.id, p.description, p.link, p.target, p.page_title
             FROM s_cms_static p
             WHERE p.parentID = ?
             ORDER BY p.position
         ';
         $staticPage['subPages'] = $this->db->fetchAll($sql, array($staticId));
     }
     return $staticPage;
 }
示例#11
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, 'added' => $this->getCurrentDateFormatted()));
         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;
         }
     }
 }
示例#12
0
 /**
  * Helper function which returns all available esd serials for the passed esd id.
  *
  * @param $esdId
  * @return array
  */
 private function getAvailableSerialsOfEsd($esdId)
 {
     return $this->db->fetchAll("SELECT s_articles_esd_serials.id AS id, s_articles_esd_serials.serialnumber as serialnumber\n            FROM s_articles_esd_serials\n            LEFT JOIN s_order_esd\n              ON (s_articles_esd_serials.id = s_order_esd.serialID)\n            WHERE s_order_esd.serialID IS NULL\n            AND s_articles_esd_serials.esdID= :esdId", array('esdId' => $esdId));
 }
示例#13
0
    /**
     * Replacement for: Shopware()->Api()->Export()->sOrderDetails(array('orderID' => $orderId));
     *
     * Returns order details for a given orderId
     *
     * @param int $orderId
     * @return array
     */
    public function getOrderDetailsByOrderId($orderId)
    {
        $sql = <<<EOT
SELECT
    `d`.`id` as `orderdetailsID`,
    `d`.`orderID` as `orderID`,
    `d`.`ordernumber`,
    `d`.`articleID`,
    `d`.`articleordernumber`,
    `d`.`price` as `price`,
    `d`.`quantity` as `quantity`,
    `d`.`price`*`d`.`quantity` as `invoice`,
    `d`.`name`,
    `d`.`status`,
    `d`.`shipped`,
    `d`.`shippedgroup`,
    `d`.`releasedate`,
    `d`.`modus`,
    `d`.`esdarticle`,
    `d`.`taxID`,
    `t`.`tax`,
    `d`.`tax_rate`,
    `d`.`esdarticle` as `esd`
FROM
    `s_order_details` as `d`
LEFT JOIN
    `s_core_tax` as `t`
ON
    `t`.`id` = `d`.`taxID`
WHERE
    `d`.`orderID` = :orderId
ORDER BY
    `orderdetailsID` ASC
EOT;
        $rows = $this->db->fetchAll($sql, ['orderId' => $orderId]);
        return $rows;
    }
示例#14
0
 public function sGetPremiumDispatchSurcharge($basket)
 {
     if (empty($basket)) {
         return false;
     }
     $sql = 'SELECT id, bind_sql FROM s_premium_dispatch WHERE type=2 AND bind_sql IS NOT NULL';
     $statements = $this->db->fetchPairs($sql);
     $sql_where = '';
     foreach ($statements as $dispatchID => $statement) {
         $sql_where .= "\n            AND ( d.id!={$dispatchID} OR ({$statement}))\n            ";
     }
     $sql_basket = array();
     foreach ($basket as $key => $value) {
         $sql_basket[] = $this->db->quote($value) . " as `{$key}`";
     }
     $sql_basket = implode(', ', $sql_basket);
     $sql_add_join = "";
     if (!empty($basket['paymentID'])) {
         $sql_add_join .= "\n                JOIN s_premium_dispatch_paymentmeans dp\n                ON d.id = dp.dispatchID\n                AND dp.paymentID={$basket['paymentID']}\n            ";
     }
     if (!empty($basket['countryID'])) {
         $sql_add_join .= "\n                JOIN s_premium_dispatch_countries dc\n                ON d.id = dc.dispatchID\n                AND dc.countryID={$basket['countryID']}\n            ";
     }
     $sql = "\n            SELECT d.id, d.calculation\n            FROM s_premium_dispatch d\n\n            JOIN ( SELECT {$sql_basket} ) b\n\n            {$sql_add_join}\n\n            LEFT JOIN (\n                SELECT dc.dispatchID\n                FROM s_articles_categories_ro ac,\n                s_premium_dispatch_categories dc\n                WHERE ac.articleID={$basket['articleID']}\n                AND dc.categoryID=ac.categoryID\n                GROUP BY dc.dispatchID\n            ) as dk\n            ON dk.dispatchID=d.id\n\n            LEFT JOIN s_user u\n            ON u.id=b.userID\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 d.active=1\n            AND (bind_weight_from IS NULL OR bind_weight_from <= b.weight)\n            AND (bind_weight_to IS NULL OR bind_weight_to >= b.weight)\n            AND (bind_price_from IS NULL OR bind_price_from <= b.amount)\n            AND (bind_price_to IS NULL OR bind_price_to >= b.amount)\n            AND (bind_instock=0 OR bind_instock IS NULL OR (bind_instock=1 AND b.instock) OR (bind_instock=2 AND b.stockmin))\n            AND (bind_laststock=0 OR (bind_laststock=1 AND b.laststock))\n            AND (bind_shippingfree=2 OR NOT b.shippingfree)\n\n            AND (d.multishopID IS NULL OR d.multishopID=b.multishopID)\n            AND (d.customergroupID IS NULL OR d.customergroupID=b.customergroupID)\n            AND dk.dispatchID IS NULL\n            AND d.type = 2\n            AND (d.shippingfree IS NULL OR d.shippingfree > b.amount)\n            {$sql_where}\n            GROUP BY d.id\n        ";
     $dispatches = $this->db->fetchAll($sql);
     $surcharge = 0;
     if (!empty($dispatches)) {
         foreach ($dispatches as $dispatch) {
             if (empty($dispatch['calculation'])) {
                 $from = round($basket['weight'], 3);
             } elseif ($dispatch['calculation'] == 1) {
                 $from = round($basket['amount'], 2);
             } elseif ($dispatch['calculation'] == 2) {
                 $from = round($basket['count_article']);
             } elseif ($dispatch['calculation'] == 3) {
                 $from = round($basket['calculation_value_' . $dispatch['id']]);
             } else {
                 continue;
             }
             $sql = "\n                SELECT `value` , `factor`\n                FROM `s_premium_shippingcosts`\n                WHERE `from` <= {$from}\n                AND `dispatchID` = {$dispatch['id']}\n                ORDER BY `from` DESC\n                LIMIT 1\n            ";
             $result = $this->db->fetchRow($sql);
             if (!$result) {
                 continue;
             }
             $surcharge += $result['value'];
             if (!empty($result['factor'])) {
                 $surcharge += $result['factor'] / 100 * $from;
             }
         }
     }
     return $surcharge;
 }
示例#15
0
 /**
  * Read translation for one or more articles
  * @param $data
  * @param $object
  * @return array
  */
 public function sGetTranslations($data, $object)
 {
     if (Shopware()->Shop()->get('skipbackend') || empty($data)) {
         return $data;
     }
     $language = Shopware()->Shop()->getId();
     $fallback = Shopware()->Shop()->get('fallback');
     $ids = $this->db->quote(array_keys($data));
     switch ($object) {
         case 'article':
             $map = array('txtshortdescription' => 'description', 'txtlangbeschreibung' => 'description_long', 'txtArtikel' => 'articleName', 'txtzusatztxt' => 'additionaltext', 'txtkeywords' => 'keywords', 'txtpackunit' => 'packunit');
             break;
         case 'configuratorgroup':
             $map = array('description' => 'groupdescription', 'name' => 'groupname');
             break;
         default:
             return $data;
     }
     $object = $this->db->quote($object);
     $sql = '';
     if (!empty($fallback)) {
         $sql .= "\n                SELECT s.objectdata, s.objectkey\n                FROM s_core_translations s\n                WHERE\n                    s.objecttype = {$object}\n                AND\n                    s.objectkey IN ({$ids})\n                AND\n                    s.objectlanguage = '{$fallback}'\n            UNION ALL\n            ";
     }
     $sql .= "\n            SELECT s.objectdata, s.objectkey\n            FROM s_core_translations s\n            WHERE\n                s.objecttype = {$object}\n            AND\n                s.objectkey IN ({$ids})\n            AND\n                s.objectlanguage = '{$language}'\n        ";
     $translations = $this->db->fetchAll($sql);
     if (empty($translations)) {
         return $data;
     }
     foreach ($translations as $translation) {
         $article = (int) $translation['objectkey'];
         $object = unserialize($translation['objectdata']);
         foreach ($object as $translateKey => $value) {
             if (isset($map[$translateKey])) {
                 $key = $map[$translateKey];
             } else {
                 $key = $translateKey;
             }
             if (!empty($value) && array_key_exists($key, $data[$article])) {
                 $data[$article][$key] = $value;
             }
         }
     }
     return $data;
 }
 private function setCategoryAvoidCustomerGroups()
 {
     $sql = "SELECT categoryID, customergroupID FROM s_categories_avoid_customergroups";
     $this->categoryAvoidCustomerGroups = $this->db->fetchAll($sql);
 }
示例#17
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;
     }
 }
示例#18
0
 /**
  * get all BasketItems
  * @return array
  */
 private function getBasketItems()
 {
     $sql = "SELECT id, ordernumber\n                FROM `s_order_basket`\n                WHERE sessionID = ?";
     return $this->db->fetchAll($sql, array($this->sessionId));
 }