Jump to content

Add column Categories in List Orders


3msweb

Recommended Posts

Hi Guys, 

 

I tried to add the category column of the product (on my site sells only one product at a time, so every order will have only one product) in AdminOrdersController file, but did not succeed. Could you give me a hand?

$this->_join = '
		LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
		INNER JOIN `'._DB_PREFIX_.'address` address ON address.id_address = a.id_address_delivery
		INNER JOIN `'._DB_PREFIX_.'country` country ON address.id_country = country.id_country
		INNER JOIN `'._DB_PREFIX_.'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = '.(int)$this->context->language->id.')
		LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
		LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')
        LEFT JOIN `'._DB_PREFIX_. 'order_detail` od ON (od.id_order = a.id_order )
		INNER JOIN `'._DB_PREFIX_. 'product` max ON (max.id_product = od.product_id )';
		$this->_orderBy = 'id_order';
		$this->_orderWay = 'DESC';
        $this->_group = 'GROUP BY a.id_order';

		$statuses = OrderState::getOrderStates((int)$this->context->language->id);
		foreach ($statuses as $status)
			$this->statuses_array[$status['id_order_state']] = $status['name'];

		$this->fields_list = array(
			'id_order' => array(
				'title' => $this->l('ID'),
				'align' => 'text-center',
				'class' => 'fixed-width-xs'
			),
            
			'reference' => array(
				'title' => $this->l('Rif.'),
				'width' => 50,

			),
			
			'customer' => array(
				'title' => $this->l('Customer'),
				'havingFilter' => true,
			),
            //viewproductsoforder
            'products' => array(
                'title' => $this->l('Products'),
                'align' => 'center',
                'width' => 150,
                'filter_key' => 'od!product_name'
            ),
			
			'categories' => array(
                'title' => $this->l('Categories'),
                'align' => 'center',
                'width' => 150,
                'filter_key' => 'max!id_category_default'
            ),
	   

I have add this

INNER JOIN `'._DB_PREFIX_. 'product` max ON (max.id_product = od.product_id )';

 

and this to field:

 

    'categories' => array(

'title' => $this->l('Categories'),
'align' => 'center',
'width' => 150,
'filter_key' => 'max!id_category_default'
),

 

 

but the page order tell me reference is ambiguos.

 

How can i solve?

 

 

 

 

 

 

 

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...