0

How to avoid custom column in search collection filter? Column not found: 1054 Unknown column 'show_in_custom_assistance' in 'where clause',

  $collection = $this->_autoSearchCollection->create();
    $collection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
    $collection->addAttributeToSelect('*')
    ->setStoreToFilter($storeid)
    ->addStoreFilter($storeid)
    ->addSearchFilter($search_arr)
    ->addMinimalPrice()
    ->addUrlRewrite()
    ->addTaxPercents();
    $collection->addCategoryFilter($category);
    // echo $collection->getSelect();

    return $collection;

1 Answer 1

2

You can use below code to remove either field or any attribute from your custom collection.

To remove attribute :

$collection->removeAttributeToSelect('show_in_custom_assistance');

To remove field/table column :

$collection->removeFieldFromSelect('show_in_custom_assistance');

Hope this help to you.

Thanks,

5
  • I was looking for this solution, but this has not worked for me. still coming in Where clause condition.
    – Mahendra
    Apr 23, 2020 at 4:58
  • I want to remove the field from where the condition
    – Mahendra
    Apr 23, 2020 at 5:19
  • You don't need to write this field in where clause if you want to remove it from the collection. Magento2 has already used this and you can check in these files for your reference : 1) vendor/magento/module-ui/DataProvider/AbstractDataProvider.php, 2) vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php Apr 23, 2020 at 5:55
  • Thanks, Pratik Got the solution.
    – Mahendra
    Apr 23, 2020 at 6:35
  • That's great to hear! Apr 23, 2020 at 7:26

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.