Jump to content

Adjusting Bestsellers Array

A-Z Hosting

Recommended Posts

What is the best way to remove free products $0.00 from my bestsellers array? $best_sellers  Has anybody ever tried to do this?  Can a smarty reiteration be used in the .tpl file and parse through the array adding those without a price greater than $0.01 to $newbestsellers?


I was just getting ready to tackle this using smarty logic, but decided I would ask her first in case it's been done before.

{include file="$tpl_dir./product-list.tpl" products=$best_sellers class='blockbestsellers tab-pane' id='blockbestsellers' active=$active_ul} 









Link to comment
Share on other sites

{foreach from=$best_sellers key=key item=value}

       {if $value.price == '$0.00'} 




    {$new_best_sellers = array_values($best_sellers)}


{include file="$tpl_dir./product-list.tpl" products=$new_best_sellers class='blockbestsellers tab-pane' id='blockbestsellers' active=$active_ul}


Unfortunately {$best_sellers[$key]=null} only leaves me with a dead broken product because the key itself isn't removed. Smarty doesn't seem to have an "unset()" function of any kind.  Other ideas?




    [0] => 

    [1] => 

    [2] => Array


            [id_product] => 541

            [id_product_attribute] => 49

            [link_rewrite] => rose-01

            [name] => Rose 01

            [description_short] => Rose 01...

            [id_category_default] => 43

            [id_image] => 541-601

            [legend] => 

            [sales] => 1



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...