<?php

namespace KupShop\FeedsBundle\Wrapper;

class PriceLevelsWrapper extends ObjectMultiWrapper
{
    protected \Product $product;

    protected static array $allPriceLevels;

    public function __construct(PriceLevelsWrapperFactory $wrapperFactory)
    {
        parent::__construct($wrapperFactory);
    }

    /** @private */
    public function setProduct(\Product $product): PriceLevelsWrapper
    {
        if (!isset(static::$allPriceLevels)) {
            static::$allPriceLevels = sqlFetchAll(sqlQueryBuilder()->select('id')->from('price_levels')->execute(), ['id' => 'id']);
        }

        $this->objects = static::$allPriceLevels;

        $this->wrapperFactory->setProduct($product);

        return $this;
    }
}
