/** * Check attribute is variable or not * * @param \XLite\Model\Product $product Product * * @return boolean */ public function isVariable(\XLite\Model\Product $product) { $result = false; foreach ($product->getVariantsAttributes() as $a) { if ($a->getId() == $this->getId()) { $result = true; break; } } return $result; }
/** * Returns product class variant attribute by name and group * * @param \XLite\Model\Product $model Product * @param string $name Attribute name * @param string $group Attribute group * * @return \XLite\Model\Attribute */ protected function findProductClassVariantAttribute($model, $name, $group) { /** @var \XLite\Model\Attribute $item */ return array_reduce($model->getVariantsAttributes()->toArray(), function ($carry, $item) use($name, $group) { return null === $carry && $name === $item->getName() && $group === ($item->getAttributeGroup() ? $item->getAttributeGroup()->getName() : '') && (bool) $item->getProductClass() ? $item : $carry; }, null); }
/** * {@inheritDoc} */ public function getVariantsAttributes() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getVariantsAttributes', array()); return parent::getVariantsAttributes(); }