Sonata\ProductBundle\Model\BaseProductProvider::getVariation PHP Метод

getVariation() публичный Метод

public getVariation ( Sonata\Component\Product\ProductInterface $product, array $choices = [] )
$product Sonata\Component\Product\ProductInterface
$choices array
    public function getVariation(ProductInterface $product, array $choices = array())
    {
        $accessor = PropertyAccess::createPropertyAccessor();
        foreach ($this->getEnabledVariations($product) as $variation) {
            foreach ($choices as $choice => $value) {
                if (!in_array($choice, $this->getVariationFields())) {
                    throw new \RuntimeException("The field '" . $choice . "' is not among the variation fields");
                }
                if ($accessor->getValue($variation, $choice) !== $value) {
                    continue 2;
                }
            }
            return $variation;
        }
        return;
    }