Jump to content

PS 1.6 Admin add ecotax on the list of the product combination


Recommended Posts

Hi everybody,

 

I want to add the ecotax on the combination list in the product's admin panel.

 

I search a little, i think i will add an override of the AdminProductsController.php

 

I find the function renderListAttributes. But i have some questions, It's possible to override only a piece of the function or i have to copy/paste the function and add my modification ?

 

Thanks in advance.

Link to comment
Share on other sites

Re all,

 

I've tested my modification. and it was done.

 

I add the ecotax on the combination list.

 

here the sample to override the function renderListAttributes, place the file AdminProductsController.php in the folder www/override/controllers/admin :

<?php
class AdminProductsController extends AdminProductsControllerCore
{
		public function renderListAttributes($product, $currency)
		{
			$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
			$this->addRowAction('edit');
			$this->addRowAction('default');
			$this->addRowAction('delete');

			$default_class = 'highlighted';

			$this->fields_list = array(
				'attributes' => array('title' => $this->l('Attribute - value pair'), 'align' => 'left'),
				'price' => array('title' => $this->l('Impact on price'), 'type' => 'price', 'align' => 'left'),
				'weight' => array('title' => $this->l('Impact on weight'), 'align' => 'left'),
				'reference' => array('title' => $this->l('Reference'), 'align' => 'left'),
				'ean13' => array('title' => $this->l('EAN-13'), 'align' => 'left'),
				'ecotax' => array('title' => $this->l('ECO TAX'), 'align' => 'left'),
				'upc' => array('title' => $this->l('UPC'), 'align' => 'left')
			);

			if ($product->id)
			{
				/* Build attributes combinations */
				$combinations = $product->getAttributeCombinations($this->context->language->id);
				$groups = array();
				$comb_array = array();
				if (is_array($combinations))
				{
					$combination_images = $product->getCombinationImages($this->context->language->id);
					foreach ($combinations as $k => $combination)
					{
						$price_to_convert = Tools::convertPrice($combination['price'], $currency);
						$price = Tools::displayPrice($price_to_convert, $currency);

						$comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
						$comb_array[$combination['id_product_attribute']]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']);
						$comb_array[$combination['id_product_attribute']]['wholesale_price'] = $combination['wholesale_price'];
						$comb_array[$combination['id_product_attribute']]['price'] = $price;
						$comb_array[$combination['id_product_attribute']]['weight'] = $combination['weight'].Configuration::get('PS_WEIGHT_UNIT');
						$comb_array[$combination['id_product_attribute']]['unit_impact'] = $combination['unit_price_impact'];
						$comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
						$comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
						$comb_array[$combination['id_product_attribute']]['upc'] = $combination['upc'];
						$comb_array[$combination['id_product_attribute']]['ecotax'] = $combination['ecotax'];
						$comb_array[$combination['id_product_attribute']]['id_image'] = isset($combination_images[$combination['id_product_attribute']][0]['id_image']) ? $combination_images[$combination['id_product_attribute']][0]['id_image'] : 0;
						$comb_array[$combination['id_product_attribute']]['available_date'] = strftime($combination['available_date']);
						$comb_array[$combination['id_product_attribute']]['default_on'] = $combination['default_on'];
						if ($combination['is_color_group'])
							$groups[$combination['id_attribute_group']] = $combination['group_name'];
					}
				}

				$irow = 0;
				if (isset($comb_array))
				{
					foreach ($comb_array as $id_product_attribute => $product_attribute)
					{
						$list = '';

						/* In order to keep the same attributes order */
						asort($product_attribute['attributes']);

						foreach ($product_attribute['attributes'] as $attribute)
							$list .= $attribute[0].' - '.$attribute[1].', ';

						$list = rtrim($list, ', ');
						$comb_array[$id_product_attribute]['image'] = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false;
						$comb_array[$id_product_attribute]['available_date'] = $product_attribute['available_date'] != 0 ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00';
						$comb_array[$id_product_attribute]['attributes'] = $list;
						$comb_array[$id_product_attribute]['name'] = $list;

						if ($product_attribute['default_on'])
							$comb_array[$id_product_attribute]['class'] = $default_class;
					}
				}
			}

			foreach ($this->actions_available as $action)
			{
				if (!in_array($action, $this->actions) && isset($this->$action) && $this->$action)
					$this->actions[] = $action;
			}

			$helper = new HelperList();
			$helper->identifier = 'id_product_attribute';
			$helper->table_id = 'combinations-list';
			$helper->token = $this->token;
			$helper->currentIndex = self::$currentIndex;
			$helper->no_link = true;
			$helper->simple_header = true;
			$helper->show_toolbar = false;
			$helper->shopLinkType = $this->shopLinkType;
			$helper->actions = $this->actions;
			$helper->list_skip_actions = $this->list_skip_actions;
			$helper->colorOnBackground = true;
			$helper->override_folder = $this->tpl_folder.'combination/';

			return $helper->generateList($comb_array, $this->fields_list);
			
			//return AdminController::renderListAttributes();  
		}
	}
?>
Link to comment
Share on other sites

  • 2 years later...

i think you are looking for this :

SELECT ps_attribute_group_lang.public_name, ps_attribute_lang.name FROM `ps_attribute` join ps_attribute_group_lang on(ps_attribute_group_lang.id_attribute_group = ps_attribute.id_attribute_group) join ps_attribute_langon (ps_attribute_lang.id_attribute = ps_attribute.id_attribute) join ps_product_attribute_shop on (ps_product_attribute_shop.id_product_attribute = ps_attribute.id_attribute) where ps_attribute.id_attribute = 189

Link to comment
Share on other sites

×
×
  • Create New...