Jump to content

Adding out_of_stock to product listings


cheekyvape

Recommended Posts

Hi

 

I would like to add

 

When out of stock
- Deny orders
- Allow orders
- Default: Deny orders
 
to the product listing page in the back office.
 
I know it requires editing of the AdminProductsController.php
 
and I thought it would be something like this?
 
        $this->fields_list['out_of_stock'] = array(
			'title' => $this->l('Out of Stock'),
			'width' => 90,
			'filter_key' => $alias.'!out_of_stock'
		);
Any help much appreciated

 

Link to comment
Share on other sites

Try:

<?php

class AdminProductsController extends AdminProductsControllerCore
{
    public function __construct()
    {
        parent::__construct();
        $this->fields_list['out_of_stock'] = array(
            'title' => $this->l('Out of Stock'),
	    'width' => 90,
            'filter_key' => 'sav!out_of_stock',
            'callback' => 'displayOutOfStock'
        );
    }
    
    public function displayOutOfStock($out_of_stock)
    {
        switch ($out_of_stock) {
            case 0: return $this->l('Deny');
            case 1: return $this->l('Allow');
            case 2: return $this->l('Default');   
        }
        
        return '';
    }
}
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...