Jump to content
Sign in to follow this  
saveplanet

[Решено] Описание категории в карточке товара

Recommended Posts

Как вывести описание категории в карточке товара? Во всех дочерних товарах.

Share this post


Link to post
Share on other sites
<modification>    
	<file name="catalog/controller/product/product.php">
		<operation>
			<search position="after"><![CDATA[$product_info = $this->model_catalog_product->getProduct($product_id);]]></search>
			<add><![CDATA[
				$allcats = $this->model_catalog_product->getCategories($product_id);
				$categories = array();
				foreach( $allcats as $allcat ) {
					$categ = $this->model_catalog_category->getCategory($allcat['category_id']);					
					$extract['name'] = $categ['name'];
					$extract['description'] = utf8_substr(strip_tags(html_entity_decode($categ['description'], ENT_QUOTES, 'UTF-8')), 0, 120) . '...';
					$categories[] = $extract;
				}
			]]></add>
		</operation>
		<operation>
			<search position="before"><![CDATA[$this->data['manufacturer'] = $product_info['manufacturer'];]]></search>
			<add><![CDATA[
				$this->data['categories'] = $categories;
			]]></add>
		</operation>
	</file>	
	<file name="catalog/view/theme/default/template/product/product.tpl">
		<operation>
			<search position="before"><![CDATA[<span><?php echo $text_model; ?></span> <?php echo $model; ?><br />]]></search>
			<add><![CDATA[
			<?php if( $categories ): ?>				
				<?php foreach( $categories as $category ): ?>
					<?php echo $category['name']; ?><br/>					
					<?php echo $category['description']; ?><br/>
				<?php endforeach; ?>
				<br />
			<?php endif; ?>
			]]></add>
		</operation>
	</file>
</modification>

 

Это сохранить с произвольным именем но в формате .XML и положить в папку vQmod/xml/

  • +1 1

Share this post


Link to post
Share on other sites


<modification>    
	<file name="catalog/controller/product/product.php">
		<operation>
			<search position="after"><![CDATA[$product_info = $this->model_catalog_product->getProduct($product_id);]]></search>
			<add><![CDATA[
				$allcats = $this->model_catalog_product->getCategories($product_id);
				$categories = array();
				foreach( $allcats as $allcat ) {
					$categ = $this->model_catalog_category->getCategory($allcat['category_id']);					
					$extract['name'] = $categ['name'];
					$extract['description'] = utf8_substr(strip_tags(html_entity_decode($categ['description'], ENT_QUOTES, 'UTF-8')), 0, 120) . '...';
					$categories[] = $extract;
				}
			]]></add>
		</operation>
		<operation>
			<search position="before"><![CDATA[$this->data['manufacturer'] = $product_info['manufacturer'];]]></search>
			<add><![CDATA[
				$this->data['categories'] = $categories;
			]]></add>
		</operation>
	</file>	
	<file name="catalog/view/theme/default/template/product/product.tpl">
		<operation>
			<search position="before"><![CDATA[<span><?php echo $text_model; ?></span> <?php echo $model; ?><br />]]></search>
			<add><![CDATA[
			<?php if( $categories ): ?>				
				<?php foreach( $categories as $category ): ?>
					<?php echo $category['name']; ?><br/>					
					<?php echo $category['description']; ?><br/>
				<?php endforeach; ?>
				<br />
			<?php endif; ?>
			]]></add>
		</operation>
	</file>
</modification>

 

Это сохранить с произвольным именем но в формате .XML и положить в папку vQmod/xml/

 

Спасибо. Но получается это xml и произвольно выводится в товаре описание, а как обернуть в шаблоне уже нужными тегами это описание? В самом шаблоне как это будет выводится?

Share this post


Link to post
Share on other sites

Доброго времени суток, как как вывести в товаре не список категорий в которых он находится (текущая реализация), а только одну к которой привязан - main_category?

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.