addUnitTranslation example

$query->select($this->fieldHelper->getPriceFields())
            ->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);
        }

        
->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();
        if ($this->config->get('calculateCheapestPriceWithMinPurchase')) {
            $query->addSelect('COUNT(DISTINCT ROUND(prices.price * priceVariant.minpurchase, 2)) as priceCount');
        } else {
            
->addSelect($this->fieldHelper->getUnitFields())
            ->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);

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