Create a query for special attribute.

@param ProductCondition $productCondition Product condition.

@return NULL|\Smile\ElasticsuiteCore\Search\Request\QueryInterface
494079
private function getSpecialAttributesSearchQuery(ProductCondition $productCondition)
    {
        $query = null;

        if ($productCondition->getAttribute() === 'sku') {
            $queryParams = [];
            $fieldName   = $this->getSearchFieldName($productCondition);

            // SKU values can be an array of value, due to the picker.
            foreach (explode(',', $productCondition->getValue()) as $value) {
                // We add all of these values as a should match sub query.
                $queryParams['should'][] = $this->prepareQuery(
                    QueryInterface::TYPE_MATCH,
                    ['field' => $fieldName, 'queryText' => trim($value), 'minimumShouldMatch' => "100%"]
                );
            }

            // One clause must match between all.
            $queryParams['minimumShouldMatch'] = 1;
            $query = $this->prepareQuery(QueryInterface::TYPE_BOOL, $queryParams);
        }

        if (in_array($productCondition->getAttribute(), array_keys($this->specialAttributesProvider->getList()))) {
            $specialAttribute = $this->specialAttributesProvider->getAttribute($productCondition->getAttribute());
            $query            = $specialAttribute->getSearchQuery();
        }

        return $query;
    }
583374
public function getDealerProduct(ConnectionInterface $con = null)
    {
        if ($this->aDealerProduct === null && ($this->id !== null)) {
            $this->aDealerProduct = ChildDealerProductQuery::create()->findPk($this->id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aDealerProduct->addDealerProductVersions($this);
             */
        }

        return $this->aDealerProduct;
    }
763534
private function retrieveProductById($productId)
    {
        // Fetch product.
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException($productId);
        }

        return $product;
    }
851582
private function addFilterByParent(ProductCollection $productCollection, $parentId)
    {
        $tableProductRelation = $productCollection->getTable('catalog_product_relation');
        $productCollection->getSelect()->join(
            ['pr' => $tableProductRelation],
            'e.entity_id = pr.child_id'
        )->where('pr.parent_id = ?', $parentId);
    }
485411
public function getAttributeValuesAction(/** @noinspection PhpUnusedParameterInspection */ $productId, $attributeId)
    {
        $result = array();

        // Get attribute for this product
        $attribute = AttributeQuery::create()->findPk($attributeId);

        if ($attribute !== null) {
            $values = AttributeAvQuery::create()
                ->joinWithI18n($this->getCurrentEditionLocale())
                ->filterByAttribute($attribute)
                ->find();
            ;

            if ($values !== null) {
                /** @var AttributeAv $value */
                foreach ($values as $value) {
                    $result[] = array('id' => $value->getId(), 'title' => $value->getTitle());
                }
            }
        }

        return $this->jsonResponse(json_encode($result));
    }
1037636
protected function buildCondition(
        Contracts\QueryEntity $meta,
        Builder $query,
        array $condition,
        $boolean = 'and'
    )
    {
        $fields = $meta->getFields();
        if (array_key_exists('data', $condition) && array_key_exists('relation', $condition['data'])) {
            $type = $fields[$condition['data']['relation']]->getType();
            if ($type instanceof Types\Relation) {
                $meta = $type->getEntity();
            } else {
                throw new RuntimeException("Field {$condition['data']['relation']} is not instance of Types\Relation");
            }
            $method = $boolean === 'or' ? 'orWhereHas' : 'whereHas';
            $query->{$method}($condition['data']['relation'], function (Builder $query) use ($meta, $condition) {
                $query->where(function (Builder $query) use ($meta, $condition) {
                    $this->getSubQuery($meta, $query, $condition['rules'], $condition['condition']);
                });
            }, ($condition['not'] ?? false ? '<' : '>='), $condition['data']['count'] ?? 1);
        } elseif (array_key_exists('condition', $condition)) {
            $query->where(function (Builder $query) use ($meta, $condition) {
                $this->getSubQuery($meta, $query, $condition['rules'], $condition['condition']);
            }, null, null, $boolean);
        } elseif (array_key_exists($condition['field'], $fields)) {
            $this->applyFilter(
                $query,
                $fields[$condition['field']],
                $condition['operator'],
                $condition['value'] ?? null,
                $boolean
            );
        } else {
            throw new RuntimeException("Field {$condition['field']} not found.");
        }
    }
1181951
private function prepareFieldValue(ProductCondition $productCondition)
    {
        $value = $productCondition->getValue();

        if (is_array($value)) {
            $value = array_filter($value);
        }

        $productCondition->setValue($value);

        return $this;
    }
924198
public function product(array $condition, array $data)
    {
        $is_product = (int) isset($data['product_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_product, $value, $condition['operator']);
    }
1305647
public function where( $condition ) {
		if ( ! $condition instanceof ConditionInterface ) {
			$condition = func_get_args();
		}

		$condition = $this->router->mergeConditionAttribute(
			$this->getAttribute( 'condition' ),
			$condition
		);

		return $this->attribute( 'condition', $condition );
	}
831752
public function addCondition(Condition\Condition $condition)
    {
        if ($this->qb->queryClass === GetItem::class) {
            throw ODMException::queryGetOperationConditionsNotSupported();
        }

        $this->condition->add($condition);

        return $this;
    }
513540
public function removeVariantAttributeRelation($productId, $attributeId)
    {
        $variant = $this->retrieveProductById($productId);
        $attribute = $this->retrieveAttributeById($attributeId);

        if (!$variant->getVariantAttributes()->contains($attribute)) {
            throw new ProductException('Variant does not have relation to attribute');
        }

        $variant->removeVariantAttribute($attribute);

        return $variant;
    }
1015725
private function getProduct($productId)
    {
        if (! isset($this->products[$productId])) {
            $product = $this->productFactory->create()
                ->setStoreId($this->model->getStoreId());
            $this->productResource->load($product, $productId);
            $this->products[$productId] = $product;
        }

        return $this->products[$productId];
    }
1202150
public function get($productId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = $fields;
        }
        $endpoint = '/admin/products/'.$productId.'.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createObject(Product::class, $response['product']);
    }
144986
public function id(array $condition, array $data)
    {
        if (empty($data['product_id'])) {
            return false;
        }

        return $this->compare($data['product_id'], $condition['value'], $condition['operator']);
    }
204789
public static ProductType createType(ProductDimensionType productDimensionType,
      @Nullable String productTypeValue) {
    Preconditions.checkNotNull(productDimensionType,
        "ProductDimensionType is required when creating a ProductType");
    ProductType productType = new ProductType();
    productType.setType(productDimensionType);
    productType.setValue(productTypeValue);
    return productType;
  }
72250
public static ProductCustomAttribute createCustomAttribute(
      ProductDimensionType productDimensionType, @Nullable String attributeValue) {
    Preconditions.checkNotNull(productDimensionType,
        "ProductDimensionType is required when creating a ProductCustomAttribute");
    ProductCustomAttribute productCustomAttribute = new ProductCustomAttribute();
    productCustomAttribute.setType(productDimensionType);
    productCustomAttribute.setValue(attributeValue);
    return productCustomAttribute;
  }
61726
public static function getInfo($productType) {
		if(! self::isInit())
			self::init();

		if(! array_key_exists($productType, self::$dhlProducts))
			return null;

		return self::$dhlProducts[$productType];
	}