cancel
Showing results for 
Search instead for 
Did you mean: 

Hide some products in grid product

Hide some products in grid product

Hello,
I would like to hide specific products in product list (admin).
The products not to be displayed start with the string S_ in the sku.
These products should not be viewed by a specific group.
How can I do?

1 REPLY 1

Re: Hide some products in grid product

First load all your Sku in which string S_ present using 
product collection load and addFieldToFilter like query used
After Get All Sku which contain string S_ disable all 
product skus using repository save
$product = $this->productRepository->get($sku);
$product->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);
$this->productRepository->save($product);

 Thank You