products_collection.filter

Allows to perform preparation actions in the product collection handling class constructor.

Shop-Script

Input (passed by reference)

$collection shopProductsCollection Product collection handling class instance.
… your plugin code …

Output

Shop-Script

Plugin code example

PHP

public function productsCollectionFilter($collection)
{
    //show only products with price above 0 in frontend categories
    $collection_hash = $collection->getHash();
    if (is_array($collection_hash) && reset($collection_hash) == 'category' && wa()->getEnv() == 'frontend') {
        $collection->addWhere('price > 0');
    }
}