addProductTranslation example


    protected function fixArticleTranslation($languageId$articleId$data)
    {
        $fallbacks = $this->connection->fetchAll(
            'SELECT id FROM s_core_shops WHERE fallback_id = :languageId',
            [':languageId' => $languageId]
        );
        $fallbacks = array_column($fallbacks, 'id');

        $data = $this->prepareArticleData($data);
        $this->addProductTranslation($articleId$languageId$data);

        $existQuery = $this->connection->prepare(
            "SELECT 1 FROM s_core_translations WHERE objectlanguage = :language AND objecttype = 'article' AND objectkey = :articleId LIMIT 1"
        );

        foreach ($fallbacks as $id) {
            // check if fallback ids contains an individual translation
->addSelect('variantCheapestPrice.ordernumber as __variant_ordernumber')
            ->addSelect('variantCheapestPrice.different_price_count as __different_price_count');

        $mainQuery->from('s_articles_prices', 'price')
            ->innerJoin('price', 's_articles_details', 'variant', 'variant.id = price.articledetailsID')
            ->innerJoin('variant', 's_articles', 'product', 'product.id = variant.articleID')
            ->leftJoin('variant', 's_core_units', 'unit', 'unit.id = variant.unitID')
            ->leftJoin('price', 's_articles_prices_attributes', 'priceAttribute', 'priceAttribute.priceID = price.id')
            ->innerJoin('price', '(' . $cheapestPriceQuery->getSQL() . ')', 'variantCheapestPrice', 'variantCheapestPrice.id = price.id');

        $this->fieldHelper->addUnitTranslation($mainQuery$context);
        $this->fieldHelper->addProductTranslation($mainQuery$context);
        $this->fieldHelper->addVariantTranslation($mainQuery$context);
        $this->fieldHelper->addPriceTranslation($mainQuery$context);

        $mainQuery->setParameter(':customerGroup', $context->getCurrentCustomerGroup()->getKey())
            ->setParameter(':fallbackCustomerGroup', $context->getFallbackCustomerGroup()->getKey())
            ->setParameter(':variants', $variantIds, Connection::PARAM_INT_ARRAY)
            ->setParameter(':priceGroupCustomerGroup', $customerGroup->getId());

        $data = $mainQuery->execute()->fetchAll(PDO::FETCH_ASSOC);

        $prices = [];
        
->leftJoin('product', 's_articles_top_seller_ro', 'topSeller', 'topSeller.article_id = product.id')
            ->leftJoin('variant', 's_articles_esd', 'esd', 'esd.articledetailsID = variant.id')
            ->leftJoin('esd', 's_articles_esd_attributes', 'esdAttribute', 'esdAttribute.esdID = esd.id')
            ->leftJoin('manufacturer', 's_media', 'manufacturerMedia', 'manufacturerMedia.path = manufacturer.img')
            ->where('variant.ordernumber IN (:numbers)')
            ->andWhere('variant.active = 1')
            ->andWhere('product.active = 1')
            ->setParameter(':numbers', $numbers, Connection::PARAM_STR_ARRAY);
        if ($this->config->get('hideNoInstock')) {
            $query->andHaving('__product_has_available_variants >= 1');
        }
        $this->fieldHelper->addProductTranslation($query$context);
        $this->fieldHelper->addVariantTranslation($query$context);
        $this->fieldHelper->addManufacturerTranslation($query$context);
        $this->fieldHelper->addUnitTranslation($query$context);
        $this->fieldHelper->addEsdTranslation($query$context);

        return $query;
    }

    private function getPriceCountQuery(string $key): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        
->addSelect($this->fieldHelper->getUnitFields());

        $query->from('s_articles_prices', 'price')
            ->innerJoin('price', 's_articles_details', 'variant', 'variant.id = price.articledetailsID')
            ->innerJoin('variant', 's_articles', 'product', 'product.id = variant.articleID')
            ->leftJoin('variant', 's_core_units', 'unit', 'unit.id = variant.unitID')
            ->leftJoin('price', 's_articles_prices_attributes', 'priceAttribute', 'priceAttribute.priceID = price.id')
            ->andWhere('price.id IN (:ids)')
            ->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        $this->fieldHelper->addUnitTranslation($query$context);
        $this->fieldHelper->addProductTranslation($query$context);
        $this->fieldHelper->addVariantTranslation($query$context);
        $this->fieldHelper->addPriceTranslation($query$context);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        $prices = [];
        foreach ($data as $row) {
            $product = $row['__price_articleID'];
            $prices[$product] = $this->priceHydrator->hydrateCheapestPrice($row);
        }

        
Home | Imprint | This part of the site doesn't use cookies.