0

In frontend side, layer filter apply because of this below code. But, how can i use this below line into rest api as well? Is it possible to get $this->getRequest() object into rest api?

Below code source file :

vendor/magento/module-layered-navigation/Block/Navigation.php

foreach ($this->filterList->getFilters($this->_catalogLayer) as $filter) {
            $filter->apply($this->getRequest());
}

Any help would be appreciated.

Thanks !!

1 Answer 1

0
 $categoryId = 7;

  $resource = ObjectManager::getInstance()- 
     >get(\Magento\Framework\App\ResourceConnection::class);
  $connection = $resource->getConnection();

  $select = $connection->select()->from(['ea' => $connection- 
  >getTableName('eav_attribute')], 'ea.attribute_id')
  ->join(['eea' => $connection->getTableName('eav_entity_attribute')], 
 'ea.attribute_id = eea.attribute_id')
 ->join(['cea' => $connection->getTableName('catalog_eav_attribute')], 
 'ea.attribute_id = cea.attribute_id')
 ->join(['cpe' => $connection->getTableName('catalog_product_entity')], 
 'eea.attribute_set_id = cpe.attribute_set_id')
 ->join(['ccp' => $connection->getTableName('catalog_category_product')], 
 'cpe.entity_id = ccp.product_id')
   ->where('cea.is_filterable = ?', 1)
   ->where('ccp.category_id = ?', $categoryId)
   ->group('ea.attribute_id');


   foreach ($select as $data) {
     return $data;
   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.