CheapestPriceField example

protected function setUp(): void
    {
        $this->builder = new CheapestPriceAccessorBuilder(
            1,
            new NullLogger()
        );
    }

    public function testWithPriceAccessor(): void
    {
        $priceField = new CheapestPriceField('cheapest_price_accessor', 'cheapest_price_accessor');
        $context = Context::createDefaultContext();

        $sql = $this->builder->buildAccessor('product', $priceField$context, 'cheapestPrice');

        static::assertSame('COALESCE((ROUND((ROUND(CAST((JSON_UNQUOTE(JSON_EXTRACT(`product`.`cheapest_price_accessor`, "$.ruledefault.currencyb7d2554b0ce847cd82f3ac9bd1c0dfca.gross")) * 1) as DECIMAL(30, 20)), 2)) * 100, 0) / 100))', $sql);
    }

    public function testWithListPriceAccessor(): void
    {
        $priceField = new CheapestPriceField('cheapest_price_accessor', 'cheapest_price_accessor');
        $context = Context::createDefaultContext();

        

        $fields->add(
            (new JsonField('calculated_cheapest_price', 'calculatedCheapestPrice'))->addFlags(new ApiAware()new Runtime(\array_merge(self::PRICE_BASELINE, ['cheapestPrice'])))
        );
        $fields->add(
            (new BoolField('is_new', 'isNew'))->addFlags(new ApiAware()new Runtime(['releaseDate']))
        );
        $fields->add(
            (new OneToOneAssociationField('seoCategory', 'seoCategory', 'id', CategoryDefinition::class))->addFlags(new ApiAware()new Runtime())
        );
        $fields->add(
            (new CheapestPriceField('cheapest_price', 'cheapestPrice'))->addFlags(new WriteProtected()new Inherited()new ApiCriteriaAware())
        );
        $fields->add(
            (new ObjectField('cheapest_price_container', 'cheapestPriceContainer'))->addFlags(new Runtime())
        );
        $fields->add(
            (new ObjectField('sortedProperties', 'sortedProperties'))->addFlags(new Runtime()new ApiAware())
        );

        $fields->add(
            (new ObjectField('sortedProperties', 'sortedProperties'))->addFlags(new Runtime()new ApiAware())
        );

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