Jump to content
Sign in to follow this  
SWORDMAN

[Решено] Минимальная цена категории в title

Recommended Posts

Подскажите пожалуйста как получить доступ к масиву $products в header tpl. Минимальную цену в категории нахожу так:

echo $products[0]['price'];
Хочу сделать "Название категории" от "xxx грн"

 

Или может есть другой способ получить мин. цену в header?

Share this post


Link to post
Share on other sites

...

if ($category_info) {

if ($category_info['seo_title']) {

$this->document->setTitle($category_info['seo_title']);

} else {

$this->document->setTitle($category_info['name']);

}

...

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {

...

>>
...

if ($category_info) {

...

if ($category_info['seo_title']) {

$this->document->setTitle($category_info['seo_title'].' от '.$products[0]['price']);

} else {

$this->document->setTitle($category_info['name'].' от '.$products[0]['price']);

}

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {

...

Share this post


Link to post
Share on other sites

Но там один недочет $products[0]['price'] - можно получить в category.tpl, а в category.php только формируется этот массив, причем где то под конец файла. Не подскажете как тогда использовать Ваше решение?

$products[0]['price']
>>

$this->data['products'][0]['price']
?

Share this post


Link to post
Share on other sites

Да, СПАСИБО, теперь работает. Только еще переместил кусок кода 

			if ($category_info['seo_title']) {
			    if(isset($this->data['products'][0]['price']))
				{
				  $this->document->setTitle($category_info['seo_title'].' от '.$this->data['products'][0]['price']);
				} else $this->document->setTitle($category_info['seo_title']);
			} else {
		  		$this->document->setTitle($category_info['name']);
			};
После

//..........

$stock_status = $result['stock_status'];
$stock_qty = $result['quantity'];

				$product_infoSword = $this->model_catalog_product->getProductSword($result['product_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,
					'special2'    => $this->currency->format($this->tax->calculate($product_infoSword['special'], $product_infoSword['tax_class_id'], $this->config->get('config_tax'))),
					'pricemax'    => $this->currency->format($this->tax->calculate($product_infoSword['price'], $product_infoSword['tax_class_id'], $this->config->get('config_tax'))),
					'tax'         => $tax,
					'rating'      => $result['rating'],
					'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),
				
'stock_status'       => $stock_status,
'stock_qty'       => $stock_qty

);

}

//..........            

if ($category_info['seo_title']) {
             if(isset($this->data['products'][0]['price']))
                {
                 $this->document->setTitle($category_info['seo_title'].' от '.$this->data['products'][0]['price']);
                } else $this->document->setTitle($category_info['seo_title']);
            } else {
                 $this->document->setTitle($category_info['name']);
            };

Share this post


Link to post
Share on other sites

так я сразу написал, что отправить этот кусок надо в самый конец - прямо перед подключением шаблона категории

...if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {...
пересмотри первый код :-)

Share this post


Link to post
Share on other sites

Точно, не досмотрел) Спасибо за помощь!)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
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.