Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Решено] Атрибуты на главной в рекомендуемых


Recommended Posts

Походу не в том разделе тему поднял, перенесите плз.

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

Вывод краткого описания получается вывести

Делаю так:

featured.php вставляю

 'description' => mb_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..', 

featured.tpl

 <div id="short-dis"><?php echo $product['description']; ?></div> 

и описание появляется под товаром в рекомендуемых

Но вывод атрибутов по аналогичной схеме не получается. Вывести их в категорию вместо описания могу. Только не понимаю почему они не выводятся на главной.

На всю страницу сыпятся ошибки

 attribute_groups in C:\wamp\www\Colozon\catalog\controller\module\featured.php on line 62 

Мне это нужно для того чтобы в дальнейшем реализовать их через tooltip и впоследствии выложить в свободный доступ.

Судя по гуглу, эта тема ещё не поднималась.

Буду благодарен за любую помощь.

Link to comment
Share on other sites


$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);

Это функция из product.php . Она используется в выводе атрибутов в описание в списке товаров. Её же я и пытаюсь использовать в рекомендуемых. Но - увы

'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),

Ps Удалось даже вывести модель товара. А вот с атрибутами хоть ты тресни

Pss Сыпятся ошибки ссылающиеся на 65 строку в featured.php

'attribute_groups' => $this->model_catalog_product->getProductAttributes($this->request->get['product_id']),

а на месте где должны выводится атрибуты - написано: Array

Link to comment
Share on other sites


Смотри, я вот так вот вывел в рекоммендуемых:

$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($product_info['product_id']);

а в ТПЛ:

<?php foreach ($products as $product) { ?>
  <div>
    <?php if ($product['thumb']) { ?>
    <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
    <?php } ?>
    <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
    <?php if ($product['price']) { ?>
    <div class="price">
	  <?php if (!$product['special']) { ?>
	  <?php echo $product['price']; ?>
	  <?php } else { ?>
	  <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
	  <?php } ?>
    </div>
    <?php } ?>
    <?php if ($product['rating']) { ?>
    <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
    <?php } ?>
    <?php if (!$catalog_mode) { ?>
    <div class="cart"><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" /></div>
    <?php } ?>
 <table class="attribute">
  <?php foreach ($attribute_groups as $attribute_group) { ?>
  <thead>
    <tr>
	  <td colspan="2"><?php echo $attribute_group['name']; ?></td>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
    <tr>
	  <td><?php echo $attribute['name']; ?></td>
	  <td><?php echo $attribute['text']; ?></td>
    </tr>
    <?php } ?>
  </tbody>
  <?php } ?>
   </table>
  </div>
  <?php } ?>

  • +1 1
Link to comment
Share on other sites

Благодарю Baco за помощь. Ошибки сыпаться перестали, но и атрибуты не выводятся.

Я наверное безнадега.

$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($product_info['product_id']);
$this->data['products'][] = array(

 'product_id' => $product_info['product_id'],

 'thumb'	 => $image,
 'name'	  => $product_info['name'],
 'price'	 => $price,
 'special'   => $special,
 'rating'	 => $rating,
 'reviews'	=> sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
 'href'	  => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
);


<div class="flhomepage-box">
  <?php foreach ($products as $product) { ?>
  <div>
	<?php if ($product['thumb']) { ?>
	<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
	<?php } ?>
	<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>

   <table class="attribute">
	  <?php foreach ($attribute_groups as $attribute_group) { ?>
	  <thead>
		<tr>
			  <td colspan="2"><?php echo $attribute_group['name']; ?></td>
		</tr>
	  </thead>
	  <tbody>
		<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
		<tr>
			  <td><?php echo $attribute['name']; ?></td>
			  <td><?php echo $attribute['text']; ?></td>
		</tr>
		<?php } ?>
	  </tbody>
	  <?php } ?>
</table>

	<?php if ($product['price']) { ?>
	<div class="price">
	  <?php if (!$product['special']) { ?>
	  <?php echo $product['price']; ?>
	  <?php } else { ?>
	  <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
	  <?php } ?>
	</div>
	<?php } ?>
  </div>

В контроллере точно не нужно вызывать функцию через if ?

Судя по всему я или не туда тыкаю ту строку, или ниче не понимаю. Хотя по логике вещей, функция стоит в массиве отвечающем непосредственно за элементы которые выводятся в товаре рекомендуемых

Link to comment
Share on other sites


Верь в себя и в свою цель... В контроллере я вставил примерно сюда:

if ($product_info) {
   if ($product_info['image']) {
 $image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']);
   } else {
 $image = false;
   }
   $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($product_info['product_id']);
   if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
 $price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
   } else {
 $price = false;
   }

   if ((float)$product_info['special']) {
 $special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
   } else {
 $special = false;
   }

  • +1 1
Link to comment
Share on other sites

очень странно почему не получается

Рекомендуемые на главной:

21e1cc6b3a36.jpg

Список товаров в категории и рекомендуемые справа:

0be22919da79.jpg

Сейчас попробую на чистом движке

  • +1 1
Link to comment
Share on other sites


О крутяк! На чистой 1,5,3,1 все сработало сразу.

Baco, ставлю огроменный плюс! Спасибо тебе, уже не раз выручаешь)

Буду думать почему же на моем магазине не работает. Может это изза темы...

  • +1 1
Link to comment
Share on other sites


Наверное атрибуты выводятся без индекса или инициализируется нулевым индексом.

Т.е. выводится первый атрибут в списке array.

  • +1 1
Link to comment
Share on other sites


Наверное атрибуты выводятся без индекса или инициализируется нулевым индексом.

Т.е. выводится первый атрибут в списке array.

тоже об этом подумал, уже разбераюсь

спасибо

  • +1 1
Link to comment
Share on other sites


В общем вот что получилось:

e739cd90f6bb.jpg

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

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

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

  • +1 1
Link to comment
Share on other sites


Апну тему

Уже неделю бьюсь головой ап стену

Baco помог вывести атрибуты на главную и в любой версии по этому принципу они выводятся, за что ему ещё раз огромное спасибо. Но, к сожалению, они всем товарам присваиваются одинаковые. Судя по всему один индекс присваивается. Я не пойму почему так происходит. Ведь по аналогичному принципу они выводятся и в категориях и никаких проблем нет. Крутил вертел код - все без толку.

Прошу помощи господа.

Вопрос к Baco - у вас таких проблем небыло?

Link to comment
Share on other sites


Приветствую, увидел щас тему продолжение (ездил в карпаты на весь этот период)... щас попробую поекспериментировать - отпишусь.

Link to comment
Share on other sites

С возвращением :) Спасибо!

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

Зы В Буковель на лыжи ездил?)

Link to comment
Share on other sites


Вот массив из контроллера:

foreach ($products as $product_id) {
  $product_info = $this->model_catalog_product->getProduct($product_id);

  if ($product_info) {
if ($product_info['image']) {
 $image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']);
} else {
 $image = false;
}
//$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($product_info['product_id']);
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
 $price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
 $price = false;
}

if ((float)$product_info['special']) {
 $special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
 $special = false;
}

if ($this->config->get('config_review_status')) {
 $rating = $product_info['rating'];
} else {
 $rating = false;
}

$this->data['products'][] = array(
 'product_id' => $product_info['product_id'],
 'thumb'	 => $image,
 'name'	  => $product_info['name'],
 'price'	 => $price,
 'attribute_groups' => $this->model_catalog_product->getProductAttributes($product_info['product_id']),
 'special'   => $special,
 'rating'	 => $rating,
 'reviews'	=> sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
 'href'	  => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
);

  }
 }

а вот из tpl-ки:

<?php if ($product['attribute_groups']) { ?>
	<table class="cat-attributes">
	  <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>

	  <tbody>
		<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
		<tr>
		  <td><?php echo $attribute['name']; ?>:</td>
		  <td><?php echo $attribute['text']; ?></td>
		</tr>
		<?php } ?>
	  </tbody>
	  <?php } ?>
	</table>
  <?php } ?>

З.Ы. Не, не в Буковель, в Межгорье...

  • +1 2
Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

А подскажите как можно взять конкретный атрибут.

Ну у меня в атрибутах указано "Площадь в м2" = 1.6

Я хочу чтобы у меня цена считалась используя данный параметр, но как мне его выковырять для страницы ПРОДУКТА.

Link to comment
Share on other sites


  • 2 weeks later...

Верь в себя и в свою цель... В контроллере я вставил примерно сюда:

if ($product_info) {
    if ($product_info['image']) {
	 $image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']);
    } else {
	 $image = false;
    }
    $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($product_info['product_id']);
    if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
	 $price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
    } else {
	 $price = false;
    }
   
    if ((float)$product_info['special']) {
	 $special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
    } else {
	 $special = false;
    }

 

Спасибо. Все сделал и работает с модулем "Рекомендуемые". Попробовал тоже самое сделать с модулями "Последние" и "Хиты продаж". Увы фокус не получился. Ошибка :(

У меня на главной выводятся три эти модуля, разметка у них должна быть одинаковая.

Link to comment
Share on other sites


для хитов и прочих модулей кроме рекомендуемых нужно писать не product_info а result 

 $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($result['product_id']);
Link to comment
Share on other sites


 

для хитов и прочих модулей кроме рекомендуемых нужно писать не product_info а result 

 $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($result['product_id']);

 

Что то ему не нравится. Ошибка

 

Notice: Undefined index: attribute_groups in... ...template\module\bestseller.tpl on line 20

 

bestseller.tpl

<div class="attributeModule">
	<?php if ($product['attribute_groups']) { ?>
		<?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
			<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
				<?php echo $attribute['text']; ?>
			<?php } ?>
		<?php } ?>
	<?php } ?>
</div>

bestseller.php

foreach ($results as $result) {
		if ($result['image']) {
			$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
		} else {
			$image = false;
		}
		$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($result['product_id']);						
		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_review_status')) {
			$rating = $result['rating'];
		} else {
			$rating = false;
		}
							
		$this->data['products'][] = array(
			'product_id' => $result['product_id'],
			'thumb'   	 => $image,
			'name'    	 => $result['name'],
			'price'   	 => $price,
			'special' 	 => $special,
			'rating'     => $rating,
			'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
			'href'    	 => $this->url->link('product/product', 'product_id=' . $result['product_id']),
		);
}
Link to comment
Share on other sites


  • 2 weeks later...

 А есть функция вывисти к примеру необходисое количество - не 20 -30 а везде по 8 атрбутов

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
 Share

×
×
  • Create New...

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.