fetchPairs example


    public function getLocalesAction()
    {
        $current = Shopware()->Container()->get('locale');
        $locales = $this->getPlugin()->getLocales();
        $locales = Shopware()->Db()->quote($locales);
        $sql = 'SELECT id, locale FROM s_core_locales WHERE id IN (' . $locales . ')';
        $locales = Shopware()->Db()->fetchPairs($sql);

        $data = [];
        foreach ($locales as $id => $locale) {
            list($l$t) = explode('_', $locale);
            $l = $current::getTranslation($l, 'language', $current);
            $t = $current::getTranslation($t, 'territory', $current);
            $data[] = [
                'id' => $id,
                'name' => "$l ($t)",
            ];
        }

        
foreach ($this->_sectionColumn as $key => $sectionColumn) {
                    if (!empty($sectionArray[$key])) {
                        $select->where($sectionColumn . '=?', $sectionArray[$key]);
                    }
                }
            } else {
                $select->where($this->_sectionColumn . '=?', $section);
            }
        }

        if ($this->_valueColumn !== '*') {
            $data = $dbTable->getAdapter()->fetchPairs($select);
        } else {
            $data = $dbTable->getAdapter()->fetchAssoc($select);
        }

        if ($this->_automaticSerialization) {
            foreach ($data as $key => $value) {
                $data[$key] = unserialize($value['allowed_classes' => false]);
            }
        }

        return $data;
    }

    public function sGetPremiumDispatchSurcharge($basket$type = 2)
    {
        if (empty($basket)) {
            return false;
        }
        $type = (int) $type;

        $statements = $this->db->fetchPairs(
            'SELECT id, bind_sql FROM s_premium_dispatch WHERE active = 1 AND type = ? AND bind_sql IS NOT NULL',
            [$type]
        );

        $sql_where = '';
        foreach ($statements as $dispatchID => $statement) {
            $sql_where .= " AND ( d.id!=$dispatchID OR ($statement)) ";

        $targetLocale = Shopware()->Container()->get('auth')->getIdentity()->locale;

        $locales = Shopware()->Plugins()->Backend()->Auth()->getLocales();

        if (($key = array_search($targetLocale->getId()$locales)) !== false) {
            unset($locales[$key]);
        }

        $locales = Shopware()->Db()->quote($locales);
        $sql = 'SELECT id, locale FROM s_core_locales WHERE id IN (' . $locales . ')';
        $locales = Shopware()->Db()->fetchPairs($sql);

        $data = [];
        foreach ($locales as $id => $locale) {
            list($l$t) = explode('_', $locale);
            $l = Zend_Locale::getTranslation($l, 'language', $targetLocale->getLocale());
            $t = Zend_Locale::getTranslation($t, 'territory', $targetLocale->getLocale());
            $data[] = [
                'id' => $id,
                'name' => "$l ($t)",
            ];
        }

        

    public function sGetDispatchBasket($article$countryID = null, $paymentID = null)
    {
        $sql_select = '';
        if (!empty($this->config->get('sPREMIUMSHIPPIUNGASKETSELECT'))) {
            $sql_select .= ', ' . $this->config->get('sPREMIUMSHIPPIUNGASKETSELECT');
        }
        $sql = 'SELECT id, calculation_sql FROM s_premium_dispatch WHERE calculation=3';
        $calculations = $this->db->fetchPairs($sql);
        if (!empty($calculations)) {
            foreach ($calculations as $dispatchID => $calculation) {
                if (empty($calculation)) {
                    $calculation = $this->db->quote($calculation);
                }
                $sql_select .= ', (' . $calculation . ') as calculation_value_' . $dispatchID;
            }
        }

        $sql = " SELECT MIN(d.instock>=b.quantity) as instock, MIN(d.instock>=(b.quantity+d.stockmin)) as stockmin, MIN(d.laststock) as laststock, SUM(d.weight*b.quantity) as weight, SUM(IF(a.id,b.quantity,0)) as count_article, MAX(b.shippingfree) as shippingfree, SUM(IF(b.modus=0,b.quantity*b.price/b.currencyFactor,0)) as amount, MAX(t.tax) as max_tax, u.id as userID
Home | Imprint | This part of the site doesn't use cookies.