<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; ecommerce</title>
	<atom:link href="http://nemops.com/tag/ecommerce/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Displaying more Supplier information on the Product Page in PrestaShop</title>
		<link>http://nemops.com/prestashop-supplier-info-product-page/</link>
		<comments>http://nemops.com/prestashop-supplier-info-product-page/#comments</comments>
		<pubDate>Wed, 18 Nov 2015 10:41:33 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Theming]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[suppliers]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2602</guid>
		<description><![CDATA[<p>Displaying more information about a product&#8217;s Supplier, directly on the product page, is quite easy in PrestaShop. It only needs an override and a tiny modification to the product template. Overriding the Product Controller Unless you want to hard-modify the original ProductController, you would need an override to assign all the necessary Supplier data to [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-supplier-info-product-page/">Displaying more Supplier information on the Product Page in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Displaying more information about a product&#8217;s Supplier, directly on the product page, is quite easy in PrestaShop. It only needs an override and a tiny modification to the product template.</p>
<p><span id="more-2602"></span></p>
<h2>Overriding the Product Controller</h2>
<p>Unless you want to hard-modify the original ProductController, you would need an override to assign all the necessary Supplier data to your product page.</p>
<p>Create a new file in <em>override/controllers/front</em>, and name it <strong>ProductController.php</strong>. Open it up and add some generic override code inside php tags:</p>
<pre class="brush: php; title: ; notranslate">
class ProductController extends ProductControllerCore
{

}
</pre>
<p>We have to override the initContentMethod</p>
<pre class="brush: php; title: ; notranslate">
class ProductController extends ProductControllerCore
{
	public function initContent()
	{
		parent::initContent();
	}
}
</pre>
<p>Make sure you call the parent at the very beginning of it, then add the following inside:</p>
<pre class="brush: php; title: ; notranslate">
if($this-&gt;product-&gt;id_supplier)
{
	
	$id_supplier_address = Address::getAddressIdBySupplierId($this-&gt;product-&gt;id_supplier);
	$supplier_address = new Address($id_supplier_address);
}
</pre>
<p>First off, we are checking the current product has a supplier. Then, we need its address id, which we use to instantiate a new Address object that contains all of the information we seek.</p>
<p>At this point, we can simply assign all we want to the template:</p>
<pre class="brush: php; title: ; notranslate">
if (Validate::isLoadedObject($supplier_address))
				{
					$this-&gt;context-&gt;smarty-&gt;assign(array(
						'supplier_country'=&gt;  $supplier_address-&gt;country,
						'supplier_company'=&gt;  $supplier_address-&gt;company,
						'supplier_address1'=&gt;  $supplier_address-&gt;address1,
						'supplier_postcode'=&gt;  $supplier_address-&gt;postcode,
						'supplier_city'=&gt;  $supplier_address-&gt;city,
						'supplier_phone'=&gt;  $supplier_address-&gt;phone,
						'supplier_state' =&gt; State::getNameById($supplier_address-&gt;id_state),
						'supplier_vat_number'=&gt;  $supplier_address-&gt;vat_number,
					));
				}

</pre>
<p>As an extra measure, we make sure the loaded address object is valid and exists</p>
<p>When you&#8217;re done modifying the file, reach the <em>cache/</em> folder and erase <strong>class_index.php</strong></p>
<div class="separator"></div>
<h2>Amending the product template</h2>
<p>Now we are ready to display our data. Open <strong>product.tpl</strong>, located in your theme&#8217;s folder. You can choose any spot, I decided to go for the area below the social links in the center column.</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
			{if $product-&gt;id_supplier}
				&lt;h4&gt;&lt;a href=&quot;{$link-&gt;getSupplierLink($product-&gt;id_supplier)}&quot;&gt;&lt;strong&gt;{$product-&gt;supplier_name}&lt;/strong&gt;&lt;/a&gt;&lt;/h4&gt;
				&lt;ul&gt;
					&lt;li&gt;{$supplier_address1}&lt;/li&gt;
					&lt;li&gt;{$supplier_postcode}&lt;/li&gt;
					&lt;li&gt;{$supplier_city}, {$supplier_state}&lt;/li&gt;
					&lt;li&gt;{$supplier_country}&lt;/li&gt;
					{if $supplier_vat_number}
						&lt;li&gt;{$supplier_vat_number}&lt;/li&gt;
					{/if}
				&lt;/ul&gt;

			{/if}	
</pre>
<p>I am obviously checking if this product has a supplier, otherwise those variables would not be assigned. Save and refresh, you might need to clear cache in the back office (<strong>Advanced Parameters, Performance</strong>). We&#8217;re done!</p>
<p><a href="http://nemops.com/wp-content/uploads/2015/11/supplier_info.png"><img src="http://nemops.com/wp-content/uploads/2015/11/supplier_info.png" alt="Displaying more Supplier information on the Product Page in PrestaShop" width="550" height="366" class="aligncenter size-full wp-image-2604" /></a></p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-supplier-info-product-page/">Displaying more Supplier information on the Product Page in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-supplier-info-product-page/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
