0

I am trying to Filter the products based on vendorid with attribute_set_id. if i use print_r in the collection i am getting the result like below

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $productCollectionFactory = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
    $collection = $productCollectionFactory
        ->create()
        ->addAttributeToSelect('*')
        ->addFieldToFilter('vendor_id', $vendorId)
        ->addFieldToFilter('attribute_set_id', array('neq' => '11'))
        ->addFieldToFilter('attribute_set_id', array('neq' => '12'))
        ->load();

     echo "<pre>";print_r($collection->getData());exit();

Output :

Array
(
    [0] => Array
        (
            [entity_id] => 508
            [attribute_set_id] => 4
            [type_id] => simple
            [sku] => simple-shop4-1
            [has_options] => 0
            [required_options] => 0
            [created_at] => 2019-08-29 09:46:36
            [updated_at] => 2019-08-29 09:46:36
            [vendor_id] => 36
            [is_salable] => 1
        )

) 

The above result is true. but when i execute i am getting the below error like

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.attribute_set_id' in 'where clause', query was: SELECT FLOOR((ROUND((e.min_price) * 1, 2)) / 10) + 1 AS range, COUNT(*) AS count FROM catalog_product_index_price AS e INNER JOIN catalog_product_entity_int AS at_vendor_id ON (at_vendor_id.entity_id = e.entity_id) AND (at_vendor_id.attribute_id = '166') AND (at_vendor_id.store_id = 0) INNER JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id INNER JOIN catalog_category_product_index_store1 AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 WHERE (at_vendor_id.value = '36') AND (e.attribute_set_id != '11') AND (e.attribute_set_id != '12') AND (stock_status_index.stock_status = 1) AND (at_vendor_id.value = '36') AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_price IS NOT NULL) GROUP BY FLOOR((ROUND((e.min_price) * 1, 2)) / 10) + 1 ORDER BY (FLOOR((ROUND((e.min_price) * 1, 2)) / 10) + 1) ASC

Anyone have any idea about this. Thanks in Advance.

  • It seems to be indexing issue. Perform full re-indexing and flush cache. – Savan Patel Aug 29 at 12:02
  • @SavanPatel Thanks for your response. But the issue still persists after reindexing also. – chris Aug 29 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.