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

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


ingenerks
 Share

Recommended Posts

Получилось сделать. Но теперь где есть атрибуты съезжает блок с корзиной влево http://whiskyburo.com/speyside

Как привязать этот блок в одном положении? Пытался прописывать в dispay: block; но это не помогает? Может кто подскажет?

Link to comment
Share on other sites


  • 1 month later...

Подскажите, пожалуйста, есть такая проблема:

атрибуты в категории выводятся, всё ок! но..

 

У меня в категории выведены товары из подкатегорий

 

'filter_sub_category' => true,

 

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

 

Подскажите, пожалуйста, как сделать так, чтобы в основной категории тоже отображались атрибуты?

 

Решено!

  • +1 1
Link to comment
Share on other sites


  • 3 months later...

Уважаемые гуру помогите пожалуйста если есть возможность реализовать данный вывод для Русской сборки OpenCart Version 2.0.1.1 (rs.7). Я начинающий, но для 1.5.5.1.2 сделал и хотел бы постепенно перейти на новую версию. Но пока не получается. Спасибо!

Link to comment
Share on other sites


  • 4 weeks later...

catalog\controller\product\category.php, 199

 

			   	 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
					'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),
					'price'	   => $price,

catalog\view\theme\default\template\product\category.tpl, 76

<div class="description">
			<?php if($product['attribute_groups']) { ?>
			<table>
				<?php foreach($product['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 } ?>
		</div>

Хочу в соседней колонке выводить определенный атрибут используя это : 

<?php if ($attr_show) { ?>
	<div class="attribute"><?php foreach($product['attribute_groups'] as $attribute_group) { ?>
		<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
		 <?php if ($attribute_group['name'] == 'Тип актива') { ?>

	

	<span class="atribute-color"><?php echo $attribute['name']; ?></span>: <?php echo $attribute['text']; ?> </br> <?php } ?><?php } ?><?php } ?>

 

    </div>
	<?php } ?>	

Где Тип актива это название группы и название атрибута. Но вот беда, тогда в соседней колонке у меня выводит все атрибуты :

<?php if ($attr_show) { ?>
	<div class="attribute"><?php foreach($product['attribute_groups'] as $attribute_group) { ?>
		<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
		<?php if (in_array($attribute['attribute_id'], $attr_array)) { ?>

	

	<span class="atribute-color"><?php echo $attribute['name']; ?></span>: <?php echo $attribute['text']; ?> </br> <?php } ?><?php } ?><?php } ?>

 

    </div>
	<?php } ?> 

и тогда остальные параметры пропадают и показывает только Тип Актива в двух местах. 

Edited by igorfelix
Link to comment
Share on other sites


  • 3 weeks later...
  • 3 months later...
  • 4 weeks later...

Подскажите пожалуйста, как вывеси атрибуты вместо описания в шаблоне категорий, для версии OpenCart 2.1.0.1

 

Все тоже самое, в controller добавляем attribute_groups после description

 

'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',

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

И в tpl вместо 

 

<p><?php echo $product['description']; ?></p>

вставляем

 

  <?php if($product['attribute_groups']) { ?>

   <table>
   <?php foreach($product['attribute_groups'] as $attribute_group) { ?>
  
   <tbody>
   <?php foreach($attribute_group['attribute'] as $attribute) { ?>
   <tr>
   <?php echo $attribute['name']; ?> - <?php echo $attribute['text']; ?> <font color="#00A7C7">/</font>
  
   </tr>
   <?php } ?>
   </tbody>
   <?php } ?>
   </table>
<?php } ?>
Link to comment
Share on other sites


  • 4 weeks later...

catalog\controller\product\category.php, 199

 

			   	 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
					'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),
					'price'	   => $price,

catalog\view\theme\default\template\product\category.tpl, 76

<div class="description">
			<?php if($product['attribute_groups']) { ?>
			<table>
				<?php foreach($product['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 } ?>
		</div

а как сделать такое же, только в Opencart 2.1.0.1?

Link to comment
Share on other sites


 

 

Все тоже самое, в controller добавляем attribute_groups после description

У меня нет 

description 

 и при добавлении в 199 строку получаю вот что - Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/u388135042/public_html/catalog/controller/product/category.php on line 200

Link to comment
Share on other sites


У меня нет 

description 

 и при добавлении в 199 строку получаю вот что - Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/u388135042/public_html/catalog/controller/product/category.php on line 200

Печально...Но у меня description тоже в 199 строке нет... Но то что description вообще нет, я с вами не согласен. К примеру ocStore 2.1.0.1 в файле catalog/controller/product/category.php description встречается 7 раз. Найдите

$data['products'][] = array(

и вставьте после 

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


 

Печально...Но у меня description тоже в 199 строке нет... Но то что description вообще нет, я с вами не согласен. К примеру ocStore 2.1.0.1 в файле catalog/controller/product/category.php description встречается 7 раз. Найдите

$data['products'][] = array(

и вставьте после 

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

Спасибо огромное! Так заработало :eek:

Link to comment
Share on other sites


  • 1 month later...

Подскажите а если мне нужно добавить атрибуты не вместо описания, а отдельным DIVом, что нужно сделать. Я делаю так как описано тут но когда в  catalog/view/product/category.php  я добавляю свой новый <div class="attributes"></div> он не выводится в браузер!

Link to comment
Share on other sites


  • 4 weeks later...

Подскажите, как нужно изменить существующий код, чтобы выводились только первые три атрибута этого товара?

<?php if($product['attribute_groups']) { ?>
			<table>
				<?php foreach($product['attribute_groups'] as $attribute_group) { ?>

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

Не по id атрибутов, а именно первые три, какие бы они там ни были.

Edited by krashman
Link to comment
Share on other sites


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

Link to comment
Share on other sites


  • 4 weeks later...

Версия ocStore 2.1.0.2.1

Решение правильное, но пишет ошибки в валидации html, чтобы этого избежать и шаблоне выводим так :

   <?php if($product['attribute_groups']) { ?>
  <ul class="list-unstyled">
  <?php foreach($product['attribute_groups'] as $attribute_group) { ?>
  <?php foreach($attribute_group['attribute'] as $attribute) { ?>
  <li><strong><?php echo $attribute['name']; ?></strong> : <?php echo $attribute['text']; ?></li>
 <?php } ?>
   <?php } ?>
 </ul>
 <?php } else { ?>
<p><?php echo $product['description']; ?></p>
  <?php } ?>       

да и еще, если у товара нет аттрибутов, выводится описание товара :)

post-696786-0-98119000-1461443929_thumb.png

Link to comment
Share on other sites


  • 2 weeks later...
  • 1 month later...

Способ, который предложил freelancer, работает на 2.1.0.2.1, но есть небольшое но: если воспользоваться стандартной сортировкой опенкарт, или фильтрами, то отображается опять описание, а не характеристики

Link to comment
Share on other sites


  • 1 month later...

catalog\controller\product\category.php, 199

 

			   	 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
					'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),
					'price'	   => $price,

catalog\view\theme\default\template\product\category.tpl, 76

<div class="description">
			<?php if($product['attribute_groups']) { ?>
			<table>
				<?php foreach($product['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 } ?>
		</div>

Подскажите а как сделать чтоб показывались к примеру первые 4 атрибута, а остальные показывались при нажатии на кнопку показать все?

Link to comment
Share on other sites


  • 4 months later...

Подскажите а как сделать чтоб показывались к примеру первые 4 атрибута, а остальные показывались при нажатии на кнопку показать все?

<div class="description">
<?php if($product['attribute_groups']) { ?>
<table>
<?php foreach($product['attribute_groups'] as $attribute_group) { ?>
<thead><!--названия групп-->
</thead><!---->
<tbody>
<?php foreach($attribute_group['attribute'] as $attribute) { ?>
<?php if(in_array($attribute['attribute_id'], array(26))) { ?>
<tr>
<b><td><?php echo $attribute['text']; ?></td></b>
</tr>
<?php } ?>
</tbody><p>
<tbody>
<?php foreach($attribute_group['attribute'] as $attribute) { ?>
<?php if(in_array($attribute['attribute_id'], array(14))) { ?>
<tr>
<td><?php echo $attribute['name']; ?>:</td>
<b><td><?php echo $attribute['text']; ?></td></b>
</tr>
<?php } ?><?php }?>
</tbody>
<?php } ?>
</table>
<?php } ?>
</div><?php }?>

Можно вообще только нужный атрибут выводить, где номер в скобочках после array это необходимый атрибут

 

ID атрибута можно узнать, если в админке клацнуть на редактирование нужного атрибута. В адресной строке будет видно

Link to comment
Share on other sites


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

 

Может кто знает, как вывести атрибуты в корзине, при оформлении товара ?

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.