getUnitFields example

ShopContextInterface $context,
        Group $customerGroup
    ) {
        /** * Contains the cheapest price logic which product price should be selected. */
        $ids = $this->getCheapestPriceIds($products$customerGroup);

        $query = $this->connection->createQueryBuilder();

        $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);
        
/* * Query to select the data of the cheapest price */
        $mainQuery = $this->connection->createQueryBuilder();

        /* * Contains the cheapest price logic which product price should be selected. */
        $cheapestPriceQuery = $this->getCheapestPriceQuery($mainQuery$criteria);

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

    public function getQuery(array $numbers, ShopContextInterface $context)
    {
        $esdQuery = $this->getEsdQuery();
        $customerGroupQuery = $this->getCustomerGroupQuery();
        $availableVariantQuery = $this->getHasAvailableVariantQuery();
        $fallbackPriceQuery = $this->getPriceCountQuery(':fallback');
        $query = $this->connection->createQueryBuilder();
        $query->select($this->fieldHelper->getArticleFields())
            ->addSelect($this->fieldHelper->getTopSellerFields())
            ->addSelect($this->fieldHelper->getVariantFields())
            ->addSelect($this->fieldHelper->getUnitFields())
            ->addSelect($this->fieldHelper->getTaxFields())
            ->addSelect($this->fieldHelper->getPriceGroupFields())
            ->addSelect($this->fieldHelper->getManufacturerFields())
            ->addSelect($this->fieldHelper->getEsdFields())
            ->addSelect('(' . $esdQuery->getSQL() . ') as __product_has_esd')
            ->addSelect('(' . $customerGroupQuery->getSQL() . ') as __product_blocked_customer_groups')
            ->addSelect('(' . $availableVariantQuery->getSQL() . ') as __product_has_available_variants')
            ->addSelect('(' . $fallbackPriceQuery->getSQL() . ') as __product_fallback_price_count')
            ->addSelect('manufacturerMedia.id as __manufacturer_img_id')
        ;
        $query->setParameter(':fallback', $context->getFallbackCustomerGroup()->getKey());
        
Home | Imprint | This part of the site doesn't use cookies.