<?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; core</title>
	<atom:link href="http://nemops.com/tag/core/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>How to (finally) override Prestashop Modules&#8217; core files</title>
		<link>http://nemops.com/override-prestashop-modules-core/</link>
		<comments>http://nemops.com/override-prestashop-modules-core/#comments</comments>
		<pubDate>Mon, 19 Jan 2015 10:39:10 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[override]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2290</guid>
		<description><![CDATA[<p>Without even letting us know, the Prestashop team finally made it possible to override Prestashop Modules&#8217; core files in version 1.6.0.11. Let&#8217;s see how! Prestashop version: 1.6.0.11 and above How to (finally) override Prestashop Modules&#8217; core files Yes, we (at last!) can now override modules&#8217; php files without messing with the core itself. It seems [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/override-prestashop-modules-core/">How to (finally) override Prestashop Modules&#8217; core files</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Without even letting us know, the Prestashop team finally made it possible to override Prestashop Modules&#8217; core files in version 1.6.0.11. Let&#8217;s see how!</p>
<p><span id="more-2290"></span></p>
<ul>
<li>Prestashop version: <strong>1.6.0.11 and above</strong></li>
</ul>
<h2>How to (finally) override Prestashop Modules&#8217; core files</h2>
<p>Yes, we (at last!) can now override modules&#8217; php files without messing with the core itself. It seems this mod has been around for a few days now, and the prestashop team, of course, didn&#8217;t let anyone now. I&#8217;d like to thank the Prestashop forum user <strong>Razaro</strong> who spotted this first.</p>
<p>Enough chitchatting. Let&#8217;s see how to override a Prestashop Module&#8217;s core. Reach the new <em>override/modules/</em> folder. For this demonstration we will override the cms block, just to illustrate the purpose. Create a new folder called <strong>blockcms</strong>, and inside it a file named <strong>blockcms.php</strong>. Here is how modules overrides work:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

if (!defined('_CAN_LOAD_FILES_'))
	exit;

class BlockCmsOverride extends BlockCms
{


}

</pre>
<p>The pattern is ModuleName<strong>Override</strong>. So in this case BlockCmsOverride. If we wanted to extend the top menu, it would have been BlockTopMenuOverride, and so on. Pretty easy to remember. Now let&#8217;s go ahead and simply add a var dump to make sure it works:</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php


if (!defined('_CAN_LOAD_FILES_'))
	exit;

class BlockCmsOverride extends BlockCms
{
	public function displayBlockCMS($column)
	{
		var_dump('testing');
		if (!$this-&gt;isCached('blockcms.tpl', $this-&gt;getCacheId($column)))
		{
			$cms_titles = BlockCMSModel::getCMSTitles($column);

			$this-&gt;smarty-&gt;assign(array(
				'block' =&gt; 1,
				'cms_titles' =&gt; $cms_titles,
				'contact_url' =&gt; (_PS_VERSION_ &gt;= 1.5) ? 'contact' : 'contact-form'
			));
		}
		return $this-&gt;display(__FILE__, 'blockcms.tpl', $this-&gt;getCacheId($column));
	}

}


</pre>
<p>Nothing fancy, it doesn&#8217;t do anything but it&#8217;s great to understand how the thing works: as with all overrides, you just have to replicate a method&#8217;s name to extend or replace it. We can also call the parent if we want, and make things more concise:</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php


if (!defined('_CAN_LOAD_FILES_'))
	exit;

class BlockCmsOverride extends BlockCms
{
	public function displayBlockCMS($column)
	{
		var_dump('testing');
		parent::displayBlockCMS($column);
	}

}


</pre>
<p>As simple as that! Think about the possibilities, and <strong>the flexibility this gives to theme developers</strong>. Of course make sure you clear the class_index./php file located in the <em>cache/</em> folder before testing it out!</p>
<p>And of course, like normal overrides, we can just create the very same &#8220;blockcms&#8221; folder in our third party module, so it will be automatically added when installed, again, like classes and controllers overrides.</p>
<div class="separator"></div>
<h2>Last mention</h2>
<p>Since this silence towards the community is getting pretty annoying, I hope the Prestashop team will soon try to have more consideration for the user and developers base, informing us when such a new feature is released. Just a small code snippet for them: </p>
<pre class="brush: php; title: ; notranslate">
if($prestashop - $community)
	die();
</pre>
<p><img src="http://nemops.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p>The post <a rel="nofollow" href="http://nemops.com/override-prestashop-modules-core/">How to (finally) override Prestashop Modules&#8217; core files</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/override-prestashop-modules-core/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
