Jump to content

About Produt-list.tpl


Recommended Posts

 

 

I´d like to list at the end of product-list.tpl all the products with stock = 0.

all products without stock on page where you are, or all products without stock for whole shop?

you can create two foreach loop, one with {if $product.quantity>=1} second with {if $product.quantity==0}

Link to comment
Share on other sites

Hi Fran,

you could change the function to get the shown Products a little:

 

edit classes/Category.php   (Make backup first, just in case...)

 

Find the function:

 

public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)

 
 
What we can do is 'hijack' the order by position:
 
public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)
{
  if (!$context)
  $context = Context::getContext();
  if ($check_access && !$this->checkAccess($context->customer->id))
    return false;
 
  $front = true;
  if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
    $front = false;
 
  if ($p < 1) $p = 1;
 
/* replace original code if (empty($order_by)) with code below */
  if (empty($order_by) or ($order_by == 'position')) {
    // $order_by = 'position';      comment out or delete this line
    $order_by = 'quantity';    // changed to order by quantity, descending order
    $order_way = 'DESC';
  }
  else
    /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */
    $order_by = strtolower($order_by);
...
 
 
What happens is, when normally the products are ordered by position in the back office list, we now change this into a list of descending quantity-s
 
Hope this helps,
pascal
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...