Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

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


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 } ?>       

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

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.