10 use Magento\Catalog\Model\ProductFactory;
12 use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
13 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
15 use Magento\CatalogSearch\Model\ResourceModel\AdvancedFactory;
16 use Magento\Directory\Model\CurrencyFactory;
133 AttributeCollectionFactory $attributeCollectionFactory,
136 CurrencyFactory $currencyFactory,
140 AdvancedFactory $advancedFactory,
143 $this->_attributeCollectionFactory = $attributeCollectionFactory;
144 $this->_catalogProductVisibility = $catalogProductVisibility;
145 $this->_catalogConfig = $catalogConfig;
146 $this->_currencyFactory = $currencyFactory;
153 $advancedFactory->create(),
154 $this->productCollectionFactory->create(),
179 $preparedSearchValue = $this->getPreparedSearchCriteria(
$attribute,
$value);
180 if (
false === $preparedSearchValue) {
185 if (
$attribute->getAttributeCode() ==
'price') {
187 $store = $this->_storeManager->getStore();
188 $currency =
$store->getCurrentCurrencyCode();
189 if ($currency !=
$store->getBaseCurrencyCode()) {
190 $rate =
$store->getBaseCurrency()->getRate($currency);
201 if (
$attribute->getBackendType() ==
'datetime') {
203 ? date(
'Y-m-d\TH:i:s\Z', strtotime(
$value[
'from']))
206 ? date(
'Y-m-d\TH:i:s\Z', strtotime(
$value[
'to']))
214 if ($condition ===
false) {
219 if (
$attribute->getBackendType() ==
'static') {
220 $attributeId =
$attribute->getAttributeCode();
224 $allConditions[
$table][$attributeId] = $condition;
226 if ($allConditions) {
227 $this->_registry->register(
'advanced_search_conditions', $allConditions);
245 $product = $this->_productFactory->create();
248 ->addHasOptionsFilter()
249 ->addDisplayInAdvancedSearchFilter()
250 ->addStoreLabel($this->_storeManager->getStore()->getId())
251 ->setOrder(
'main_table.attribute_id',
'asc')
268 if ($this->_productCollection ===
null) {
269 $collection = $this->productCollectionFactory->create();
289 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
290 ->setStore($this->_storeManager->getStore())
294 ->setVisibility($this->_catalogProductVisibility->getVisibleInSearchIds());
309 $this->_searchCriterias[] = [
'name' =>
$attribute->getStoreLabel(),
'value' =>
$value];
329 if (isset(
$value[
'currency'])) {
331 $currencyModel = $this->_currencyFactory->create()->load(
$value[
'currency']);
332 $from = $currencyModel->format(
$value[
'from'], [],
false);
333 $to = $currencyModel->format(
$value[
'to'], [],
false);
335 $currencyModel =
null;
338 if (strlen(
$value[
'from']) > 0 && strlen(
$value[
'to']) > 0) {
342 $currencyModel ? $from :
$value[
'from'],
343 $currencyModel ? $to :
$value[
'to']
347 $value =
__(
'%1 and greater', $currencyModel ? $from :
$value[
'from']);
358 if ((
$attribute->getFrontendInput() ==
'select' ||
361 foreach (
$value as $key => $val) {
364 if (is_array(
$value[$key])) {
setData($key, $value=null)
$_attributeCollectionFactory
getData($key='', $index=null)
elseif(isset( $params[ 'redirect_parent']))
addSearchCriteria($attribute, $value)
$productCollectionFactory
$_catalogProductVisibility
__construct(Context $context, Registry $registry, AttributeCollectionFactory $attributeCollectionFactory, Visibility $catalogProductVisibility, Config $catalogConfig, CurrencyFactory $currencyFactory, ProductFactory $productFactory, StoreManagerInterface $storeManager, ProductCollectionFactory $productCollectionFactory, AdvancedFactory $advancedFactory, array $data=[])
prepareProductCollection($collection)