I have used Alex Branding product filling block on my blogs page. It is showing 12 products right now.
However, there are 500 products, but i am only able to see the same 12 products. I wanted to add a shuffle functionality to these 500 products and show 12 by shuffling.
First i just added
shuffle($product_ids);
inside fn_ab__product_fillings_get_search_products function inside func.php of this ab_product_filling addon. And returned shuffled products. But it shuffled only if i clear the cache.
Then, to disable the cache, i override blocks.php and blocks.functionality.php files by adding blocks.post.php and blocks.functionality.post.php files inside my my_changes/schemas/block_manager/ folder.
What i did:
$schema['products']['cache']['disable_cache_when']['callable_handlers'] = array(
array('fn_block_disable_cache_for_your_filling', array('$block_data'))
);
return $schema;
inside blocks.post.php and then i also created a function inside blocks.functionality.post.php as following:
function fn_block_disable_cache_for_your_filling($block_data)
{
// Disable cache for your filling type
if (isset($block_data['content']['items']['filling'])
&& $block_data['content']['items']['filling'] == 'ab__pf_search'
) {
return true;
}
return false;
}
But i am still not able to shuffle the products, did i miss smth here, can someone help me with that.
Thanks.