/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { $this->checkLocaleAndScope($attribute, $locale, $scope, 'media'); if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) { $this->checkValue($attribute, $value); } $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope); $field = sprintf('%s.%s.originalFilename', ProductQueryUtility::NORMALIZED_FIELD, $field); switch ($operator) { case Operators::NOT_EQUAL: $this->qb->field($field)->exists(true); $this->qb->field($field)->notEqual($value); break; case Operators::IS_NOT_EMPTY: $this->qb->field($field)->exists(true); break; case Operators::IS_EMPTY: $this->qb->field($field)->exists(false); break; default: $value = $this->prepareValue($operator, $value); $this->qb->field($field)->equals($value); } return $this; }
/** * {@inheritdoc} */ public function addAttributeSorter(AttributeInterface $attribute, $direction, $locale = null, $scope = null) { $sortField = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope); $this->qb->sort(ProductQueryUtility::NORMALIZED_FIELD . '.' . $sortField, $direction); $this->qb->sort('_id'); return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { $this->checkLocaleAndScope($attribute, $locale, $scope, 'boolean'); if (!is_bool($value)) { throw InvalidArgumentException::booleanExpected($attribute->getCode(), 'filter', 'boolean', gettype($value)); } $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope); $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field); $this->applyFilter($field, $operator, $value); return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { $this->checkLocaleAndScope($attribute, $locale, $scope, 'price'); if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) { $this->checkValue($attribute, $value); $value['data'] = (double) $value['data']; } $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope); $field = sprintf('%s.%s.%s.data', ProductQueryUtility::NORMALIZED_FIELD, $field, $value['currency']); $this->applyFilter($field, $operator, $value['data']); return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { $this->checkLocaleAndScope($attribute, $locale, $scope, 'date'); if (Operators::IS_EMPTY === $operator || Operators::IS_NOT_EMPTY === $operator) { $value = null; } else { $value = $this->formatValues($attribute->getCode(), $value); } $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope); $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field); $this->applyFilter($field, $operator, $value); return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { $this->checkLocaleAndScope($attribute, $locale, $scope, 'number'); if (Operators::IS_EMPTY !== $operator) { $field = $options['field']; $this->checkValue($field, $value); if (FieldFilterHelper::CODE_PROPERTY === FieldFilterHelper::getProperty($field)) { $value = $this->valueCodesToIds($attribute, $value); } } $field = sprintf('%s.%s.id', ProductQueryUtility::NORMALIZED_FIELD, ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope)); $this->applyFilter($operator, $value, $field); return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { try { $options = $this->resolver->resolve($options); } catch (\Exception $e) { throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'string'); } $this->checkLocaleAndScope($attribute, $locale, $scope, 'string'); if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) { $this->checkValue($options['field'], $value); } $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope); $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field); $this->applyFilter($field, $operator, $value); return $this; }
/** * {@inheritdoc} */ public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = []) { try { $options = $this->resolver->resolve($options); } catch (\Exception $e) { throw InvalidArgumentException::expectedFromPreviousException($e, $attribute->getCode(), 'filter', 'options'); } $this->checkLocaleAndScope($attribute, $locale, $scope, 'options'); if (Operators::IS_EMPTY !== $operator && Operators::IS_NOT_EMPTY !== $operator) { $this->checkValue($options['field'], $value); if (FieldFilterHelper::CODE_PROPERTY === FieldFilterHelper::getProperty($options['field'])) { $value = $this->objectIdResolver->getIdsFromCodes('option', $value, $attribute); } else { $value = array_map('intval', $value); } } $field = sprintf('%s.%s.id', ProductQueryUtility::NORMALIZED_FIELD, ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope)); $this->applyFilter($field, $operator, $value); return $this; }