/** * After load * * @param LifecycleEventArgs $args */ public function postLoad(LifecycleEventArgs $args) { $object = $args->getObject(); if (!$object instanceof ProductInterface && !$object instanceof AttributeOptionInterface) { return; } if ($this->context->hasLocaleCode()) { $object->setLocale($this->context->getLocaleCode()); } }
/** * {@inheritdoc} */ public function addFieldFilter($field, $operator, $value) { $field = sprintf("%s.%s.%s-%s", ProductQueryUtility::NORMALIZED_FIELD, 'completenesses', $this->context->getScopeCode(), $this->context->getLocaleCode()); $value = intval($value); if ($operator === '=') { $this->qb->field($field)->equals($value); } else { $this->qb->field($field)->lt($value); } return $this; }
/** * Prepare join to attribute condition with current locale and scope criterias * * @param AbstractAttribute $attribute the attribute * @param string $joinAlias the value join alias * * @return string */ public function prepareCondition(AbstractAttribute $attribute, $joinAlias) { $condition = $joinAlias . '.attribute = ' . $attribute->getId(); if ($attribute->isLocalizable()) { $condition .= ' AND ' . $joinAlias . '.locale = ' . $this->qb->expr()->literal($this->context->getLocaleCode()); } if ($attribute->isScopable()) { $condition .= ' AND ' . $joinAlias . '.scope = ' . $this->qb->expr()->literal($this->context->getScopeCode()); } return $condition; }
function let(QueryBuilder $qb, CatalogContext $context) { $context->getLocaleCode()->willReturn('en_US'); $context->getScopeCode()->willReturn('mobile'); $this->beConstructedWith($qb, $context); $qb->getRootAliases()->willReturn(array('p')); }
function let(Builder $queryBuilder, CatalogContext $context) { $context->getLocaleCode()->willReturn('en_US'); $context->getScopeCode()->willReturn('mobile'); $this->beConstructedWith($queryBuilder, $context); $queryBuilder->field(Argument::any())->willReturn($queryBuilder); }
/** * {@inheritdoc} */ public function addFieldSorter($field, $direction) { $field = sprintf("%s.%s.label.%s", ProductQueryUtility::NORMALIZED_FIELD, $field, $this->context->getLocaleCode()); $this->qb->sort($field, $direction); return $this; }
function let(CatalogContext $context) { $context->getLocaleCode()->willReturn('en_US'); $context->getScopeCode()->willReturn('mobile'); $this->beConstructedWith($context); }
/** * {@inheritdoc} */ protected function createFilename() { $dateTime = new \DateTime(); return sprintf('products_export_%s_%s_%s.%s', $this->catalogContext->getLocaleCode(), $this->catalogContext->getScopeCode(), $dateTime->format('Y-m-d_H-i-s'), $this->getFormat()); }
/** * Normalize the field name from attribute and catalog context * * @param AbstractAttribute $attribute * @param CatalogContext $context * * @return string */ public static function getNormalizedValueFieldFromAttribute(AbstractAttribute $attribute, CatalogContext $context) { return self::getNormalizedValueField($attribute->getCode(), $attribute->isLocalizable(), $attribute->isScopable(), $attribute->isLocalizable() ? $context->getLocaleCode() : null, $attribute->isScopable() ? $context->getScopeCode() : null); }