/** * Return modifier title * * @return string */ protected function getModifierTitle() { $modifiers = array(); foreach ($this->getAttrValues() as $k => $value) { foreach ($value::getModifiers() as $field => $v) { if (!isset($modifiers[$field])) { $modifiers[$field] = 0; } $modifiers[$field] += (-1 + 2 * $k) * $value->getAbsoluteValue($field); } } foreach ($modifiers as $field => $modifier) { if (0 == $modifier) { unset($modifiers[$field]); } else { $modifiers[$field] = \XLite\Model\AttributeValue\AttributeValueSelect::formatModifier($modifier, $field); } } return $modifiers ? ' <span>(' . implode(', ', $modifiers) . ')</span>' : ''; }
/** * Constructor * * @param array $data Entity properties OPTIONAL * * @return void */ public function __construct(array $data = array()) { $this->variants = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct($data); }
/** * Return value is selected or not flag * * @param \XLite\Model\AttributeValue\AttributeValueSelect $value Value * * @return boolean */ protected function isSelectedValue(\XLite\Model\AttributeValue\AttributeValueSelect $value) { $selectedIds = $this->getSelectedIds(); return isset($selectedIds[$value->getAttribute()->getId()]) ? $selectedIds[$value->getAttribute()->getId()] == $value->getId() : $value->isDefault(); }
/** * {@inheritDoc} */ public function prepareEntityBeforeCommit($type) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type)); return parent::prepareEntityBeforeCommit($type); }
/** * Return field value * * @param \XLite\Model\AttributeValue\AttributeValueSelect $attributeValue Attribute value * * @return mixed */ protected function getFieldValue($attributeValue) { return $attributeValue && $this->getAttribute() && $this->getAttribute()->getProduct() ? $attributeValue->getAttributeOption()->getName() : $attributeValue; }