Jump to content
Sign in to follow this  
Rex4r

Вывод веса и количества товаров в категориях.

Recommended Posts

День добрый. Знакомство с опенкартом начал не так давно, потому прошу не кидаться тапками)

 

Мне нужно вывести в категориях под каждым товаром его вес и количество товара на складе. В карточке товара реализовал это с помощью добавления в контроллер продукта 

 

после этого:

if ($product_info) {

вот этого:

$this->data['kolvo'] = $product_info['quantity'];
$this->data['weight'] = $product_info['weight'];
$this->data['weight_class_id'] = $product_info['weight_class_id'];

Как сделать тоже самое для категории?

 

ocStore 1.5.5.1.2

Share this post


Link to post
Share on other sites

Немного разобрался. В контроллере категорий дописал после этого:

foreach ($results as $result) {

вот это:

$this->data['kolvo'] = $result['quantity'];
$this->data['weight'] = $result['weight'];
$this->data['weight_class_id'] = $result['weight_class_id'];

Но теперь возникла проблема с тем, что для всех товаров выводится кол-во и вес последнего товара. Пока не понял почему.

 

Вот код из контроллера:

foreach ($results as $result) {
	if ($result['image']) {
		$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
	} else {
		$image = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
	}
	
	if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
		$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
	} else {
		$price = false;
	}
 	
  	if ((float)$result['special']) {
 		$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
 	} else {
 		$special = false;
 	}	
 	
 	if ($this->config->get('config_tax')) {
 		$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
 	} else {
 		$tax = false;
 	} 	
 	
 	if ($this->config->get('config_review_status')) {
 		$rating = (int)$result['rating'];
 	} else {
 		$rating = false;
 	}
 	
 	/****************************сколько****************************/
 	$this->data['quantity'] = $result['quantity'];
 	/****************************сколько****************************/
 	/******************************вес******************************/
 	$this->data['weight'] = $result['weight'];
 	$this->data['weight_class_id'] = $result['weight_class_id'];
 	/******************************вес******************************/
 	
 	
 	$this->data['products'][] = array(
 		'product_id'  => $result['product_id'],
 		'thumb'       => $image,
 		'name'        => $result['name'],
 		'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '..',
 		'price'       => $price,
 		'special'     => $special,
 		'tax'         => $tax,
 		'rating'      => $result['rating'],
		/****************************сколько****************************/
 		'quantity'       => $result['quantity'],
		/****************************сколько****************************/
 		/******************************вес******************************/
 		'weight' 	  => $result['weight'],
 		'weight_class_id' => $result['weight_class_id'],
 		/******************************вес******************************/
 		'reviews'     => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
 		'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
 	);
 }

Share this post


Link to post
Share on other sites

Разобрался. ошибка была в tpl не ту переменную выводил.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.