Db example



        return Shopware()->Db()->fetchAssoc($sql[$sendTime]);
    }

    /** * @param int[] $orderIds * * @return array */
    public function getCustomers($orderIds)
    {
        $orderIds = Shopware()->Db()->quote($orderIds);
        $sql = " SELECT b.orderID, b.company AS billing_company, b.department AS billing_department, b.salutation AS billing_salutation, u.customernumber, b.firstname AS billing_firstname, b.lastname AS billing_lastname, b.street AS billing_street, b.zipcode AS billing_zipcode, b.city AS billing_city, b.phone AS phone, b.phone AS billing_phone, b.countryID AS billing_countryID, bc.countryname AS billing_country, bc.countryiso AS billing_countryiso, bca.name AS billing_countryarea, bc.countryen AS billing_countryen, b.ustid, ba.text1 AS billing_text1, ba.text2 AS billing_text2, ba.text3 AS billing_text3, ba.text4 AS billing_text4, ba.text5 AS billing_text5, ba.text6 AS billing_text6, b.orderID as orderID, s.company AS shipping_company, s.department AS shipping_department, s.salutation AS shipping_salutation, s.firstname AS shipping_firstname, s.lastname AS shipping_lastname, s.street AS shipping_street, s.zipcode AS shipping_zipcode, s.city AS shipping_city, s.countryID AS shipping_countryID, sc.countryname AS shipping_country, sc.countryiso AS shipping_countryiso, sca.name AS shipping_countryarea, sc.countryen AS shipping_countryen, sa.text1 AS shipping_text1, sa.text2 AS shipping_text2, sa.text3 AS shipping_text3, sa.text4 AS shipping_text4, sa.text5 AS shipping_text5, sa.text6 AS shipping_text6, u.*, g.id AS preisgruppe, g.tax AS billing_net FROM s_order_billingaddress as b LEFT JOIN s_order_shippingaddress as s ON s.orderID = b.orderID LEFT JOIN s_user as u ON b.userID = u.id LEFT JOIN s_user_addresses as ub ON u.default_billing_address_id = ub.id AND u.id = ub.user_id LEFT JOIN s_core_countries as bc ON bc.id = b.countryID LEFT JOIN s_core_countries as sc ON sc.id = s.countryID LEFT JOIN s_core_customergroups as g ON u.customergroup = g.groupkey LEFT JOIN s_core_countries_areas bca ON bc.areaID = bca.id LEFT JOIN s_core_countries_areas sca ON sc.areaID = sca.id LEFT JOIN s_order_billingaddress_attributes ba ON b.id = ba.billingID LEFT JOIN s_order_shippingaddress_attributes sa ON s.id = sa.shippingID WHERE b.orderID IN (
protected $countryRepository;

    /** * Deactivates the authentication for the performOrderRedirect action * This is used in the performOrder action */
    public function init()
    {
        if ($this->Request()->getActionName() === 'performOrderRedirect') {
            Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        }
        $currency = Shopware()->Db()->fetchRow(
            'SELECT templatechar as sign, (symbol_position = 16) currencyAtEnd FROM s_core_currencies WHERE standard = 1'
        );

        $this->View()->assign('currency', $currency);

        parent::init();
    }

    /** * {@inheritdoc} */

        $articles = Shopware()->Db()->fetchAssoc($sql);
        $data = [
            'count' => \count($articles),
            'numbers' => array_keys($articles),
        ];

        if (empty($articles)) {
            return $data;
        }

        $job = $args->getJob();

        


        $stmt = Shopware()->Db()->query($sql[
            'endDate' => $endDate,
            'startDate' => $startDate,
        ]);

        $orders = [];

        while ($order = $stmt->fetch()) {
            foreach ($order as $key => $value) {
                if (empty($value)) {
                    $order[$key] = 0;
                }
            }
            $this->Request()->setParam('limit', null);
        }
        parent::preDispatch();
    }

    /** * @return void */
    public function init()
    {
        parent::init();
        $currency = Shopware()->Db()->fetchRow(
            'SELECT templatechar as sign, (symbol_position = 16) currencyAtEnd FROM s_core_currencies WHERE standard = 1'
        );

        $this->View()->assign('analyticsCurrency', $currency);
    }

    /** * {@inheritdoc} */
    
if (!empty($currentController) && !empty($sessionId)) {
            $userId = (int) $request->getSession()->get('sUserId');
            $userAgent = (string) $request->getServer('HTTP_USER_AGENT');
            $sql = ' UPDATE s_order_basket SET lastviewport = ?, useragent = ?, userID = ? WHERE sessionID=? ';
            Shopware()->Db()->query($sql[
                $currentController$userAgent,
                $userId$sessionId,
            ]);
        }
    }

    /** * @return bool */
    public function shouldRefreshLog(Enlight_Controller_Request_Request $request)
    {
        
        $sql = "SELECT partnerID, ROUND(SUM((o.invoice_amount_net-o.invoice_shipping_net)/currencyFactor),2) AS `revenue` FROM `s_order` as o WHERE o.status != 4 AND o.status != -1 AND o.partnerID <> '' GROUP BY o.partnerID";
        $revenues = Shopware()->Db()->fetchAssoc($sql);

        // Get newsletters         /** @var Query<array<string, mixed>> $query */
        $query = $this->getCampaignsRepository()->getListNewslettersQuery($filter$sort$limit$offset);

        $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $paginator = $this->getModelManager()->createPaginator($query);

        // Returns the total count of the query         $totalResult = $paginator->count();

        

    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)",
            ];
EOD;

        foreach ($emotion->getElements() as $el) {
            $key = $this->getElementIdentifier($el);
            $oldObjectKeys[$key] = $el->getId();
        }

        foreach ($clonedEmotion->getElements() as $el) {
            $key = $this->getElementIdentifier($el);

            Shopware()->Db()->executeQuery($sql[
                ':objectKey' => $el->getId(),
                ':oldObjectKey' => $oldObjectKeys[$key],
            ]);
        }
    }

    /** * creates a unique identifier string based on the grid position */
    private function getElementIdentifier(Element $el): string
    {
        
/** * Event listener method which fired before the model will be removed (DELETE) * over Shopware()->Models()->persist() / ->flush(). * * Removes the released resource. * * @ORM\PreRemove() */
    public function onRemove()
    {
        $sql = 'DELETE FROM s_core_acl_roles WHERE resourceID = ?';
        Shopware()->Db()->query($sql[$this->id]);
    }

    /** * Returns the string identifier of the Resource * * @return string */
    public function getResourceId()
    {
        return $this->name;
    }
}
if ($this->View()->getAssign('sStatus')['code'] == 3) {
                if ($this->View()->getAssign('sStatus')['isNewRegistration']) {
                    Shopware()->Modules()->Admin()->sNewsletterSubscription(Shopware()->System()->_POST['newsletter'], true);
                    $hash = Random::getAlphanumericString(32);
                    $data = serialize(Shopware()->System()->_POST->toArray());

                    $link = $this->Front()->ensureRouter()->assemble(['sViewport' => 'newsletter', 'action' => 'index', 'sConfirmation' => $hash]);

                    $this->sendMail(Shopware()->System()->_POST['newsletter'], 'sOPTINNEWSLETTER', $link);

                    Shopware()->Db()->query(' INSERT INTO s_core_optin (datum,hash,data,type) VALUES ( now(),?,?,"swNewsletter" ) ', [$hash$data]);
                }

                $this->View()->assign('sStatus', ['code' => 3, 'message' => Shopware()->Snippets()->getNamespace('frontend')->get('sMailConfirmation')]);
            }
        }
    }

    

    public function getCachedTime()
    {
        // Get elementId in order to read/write config later         $sql = "SELECT `id` FROM `s_core_config_elements` WHERE `name` LIKE 'routerlastupdate'";
        $elementId = Shopware()->Db()->fetchOne($sql);
        $shopId = Shopware()->Shop()->getId();

        // Read config         $sql = ' SELECT v.value FROM s_core_config_elements e, s_core_config_values v WHERE v.element_id=e.id AND e.id=? AND v.shop_id=? ';
        $cachedTime = Shopware()->Db()->fetchOne($sql[$elementId$shopId]);
        if (!empty($cachedTime)) {
            $cachedTime = unserialize($cachedTime['allowed_classes' => false]);
        }
/** * Helper function to remove product details for a given product * * @param ProductModel $article * * @return void */
    protected function removeArticleDetails($article)
    {
        $sql = 'SELECT id FROM s_articles_details WHERE articleID = ? AND kind != 1';

        foreach (Shopware()->Db()->fetchAll($sql[$article->getId()]) as $detail) {
            $query = $this->getRepository()->getRemoveAttributesQuery($detail['id']);
            $query->execute();

            $query = $this->getRepository()->getRemoveImageQuery($detail['id']);
            $query->execute();

            $sql = 'DELETE FROM s_article_configurator_option_relations WHERE article_id = ?';
            $this->getManager()->getConnection()->executeQuery($sql[$detail['id']]);

            $sql = 'DELETE FROM s_articles_prices WHERE articledetailsID = ?';
            $this->getManager()->getConnection()->executeQuery($sql[$detail['id']]);

            

    public function getPathByQuery($query = null, $separator = '>', $parents = false)
    {
        trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be private with 5.8.', __CLASS__, __METHOD__), E_USER_DEPRECATED);

        if (empty($query)) {
            $where = 'parent=1';
        } elseif (is_numeric($query)) {
            $where = 'parent=' . (int) $query;
        } else {
            $where = 'description LIKE ' . Shopware()->Db()->quote('%' . trim($query) . '%');
        }

        $paths = [];

        $sql = ' SELECT id, description as name, parent FROM s_categories WHERE ' . $where . ' ORDER BY parent DESC, name ';
        $result = Shopware()->Db()->fetchAll($sql);
        


        /** @var Shopware_Models_Document_Order $documentOrder */
        $documentOrder = Enlight_Class::Instance('Shopware_Models_Document_Order', [$orderID$config]);

        $document->setOrder($documentOrder);

        $document->setConfig($config);

        $document->setDocumentId($documentID);
        if (!empty($orderID)) {
            $document->_subshop = Shopware()->Db()->fetchRow(
                "SELECT s.id, m.document_template_id as doc_template_id, m.template_id as template_id, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.document_template_id) as doc_template, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.template_id) as template, s.id as isocode, s.locale_id as locale FROM s_order, s_core_shops s LEFT JOIN s_core_shops m ON m.id=s.main_id OR (s.main_id IS NULL AND m.id=s.id) WHERE s_order.language = s.id AND s_order.id = ?",
Home | Imprint | This part of the site doesn't use cookies.