Jump to content

Adjusting Bestsellers Array


A-Z Hosting
 Share

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.

 

1.6.0.14

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

 

Wil

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

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

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

          {$best_sellers[$key]=null}

       {/if} 

    {/foreach} 

    {$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?

 


Array

(

    [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

            ---snipp-----

 

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More