<?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>All Websites</title>
	<atom:link href="http://allwebsites.be/en/feed/" rel="self" type="application/rss+xml" />
	<link>http://allwebsites.be/en/</link>
	<description>Just another All Wordpress Sites site</description>
	<lastBuildDate>Tue, 31 May 2011 18:32:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Catalog Rules don&#8217;t always get applied when saving a product in Magento 1.4.2.0</title>
		<link>http://allwebsites.be/en/catalog-rules-dont-always-get-applied-when-saving-a-product-in-magento-1-4-2-0/</link>
		<comments>http://allwebsites.be/en/catalog-rules-dont-always-get-applied-when-saving-a-product-in-magento-1-4-2-0/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 23:38:09 +0000</pubDate>
		<dc:creator>Wouter Samaey</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Catalog Rules]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento 1.4.2.0]]></category>

		<guid isPermaLink="false">http://allwebsites.be/?p=1422</guid>
		<description><![CDATA[A bug in Magento 1.4.2.0 which causes catalog rules not to be applied when saving or creating a product in your catalog.]]></description>
			<content:encoded><![CDATA[<p>I recently stumbled upon a bug in Magento 1.4.2.0 which hasn&#8217;t been covered online yet, and causes catalog rules to break sometimes. The &#8220;sometimes&#8221; part has to do with the order in which you created the rules, or more specifically the last rule inserted into the database is the one actually working. All other rules won&#8217;t get applied when saving the product.</p>
<p>The only way out of this, is to open each rule and save and apply it one at a time. Hitting the &#8220;Apply All Rules&#8221; button doesn&#8217;t work.</p>
<h2>The Cause</h2>
<p>After saving a product (new or existing) an event fires triggering the Mage_CatalogRule_Model_Observer::applyAllRulesOnProduct function.</p>
<pre class="brush: php; title: ; notranslate">
    public function applyAllRulesOnProduct($observer)
    {
        $product = $observer-&gt;getEvent()-&gt;getProduct();
        if ($product-&gt;getIsMassupdate()) {
            return;
        }

        $productWebsiteIds = $product-&gt;getWebsiteIds();

        $rules = Mage::getModel('catalogrule/rule')-&gt;getCollection()
            -&gt;addFieldToFilter('is_active', 1);

        foreach ($rules as $rule) {
            if (!is_array($rule-&gt;getWebsiteIds())) {
                $ruleWebsiteIds = (array)explode(',', $rule-&gt;getWebsiteIds());
            } else {
                $ruleWebsiteIds = $rule-&gt;getWebsiteIds();
            }
            $websiteIds = array_intersect($productWebsiteIds, $ruleWebsiteIds);
            $rule-&gt;applyToProduct($product, $websiteIds);
        }
        return $this;
    }
</pre>
<p>This function is responsible for applying all the rules to the single product you just edited. In this function, all rules get loaded and applied to the product one at a time.</p>
<p>Now, when we take a look at the Mage_CatalogRule_Model_Mysql4_Rule::applyToProduct function, there&#8217;s a lot going on.</p>
<ol>
<li>The catalogrule_product table loses all records related to your product and the current rule.</li>
<li>If the rule is not valid, the catalogrule_product_price table loses all records related to your product.</li>
</ol>
<p>Now this is a problem! All rule prices get dropped, regardless of the other (good) rules, because the current rule is invalid. I was in fact amazed to find this kind of poor logic, but hey, we&#8217;ll fix it in a minute :p So, here you have it. What will happen in reality goes like this:</p>
<ol>
<li>Processing rule A -> Invalid -> Delete all rows for the product</li>
<li>Processing rule B -> Invalid -> Delete all rows for the product</li>
<li>Processing rule C -> Valid -> Writing new prices</li>
<li>Processing rule D -> Invalid -> Delete all rows for the product</li>
</ol>
<p>So rule C did run, but it&#8217;s hard work got deleted immediately after. Depending on how the rules are ordered in your database (table catalogrule), you may actually see some products discounted, given that rule C was your last one.</p>
<h2>The Solution</h2>
<p>Now, I&#8217;ve given this a lot of thought, how to best deal with this problem, and not needing to change too much core code. This is what I can up with, and it will work just fine on Magento 1.4.2.0. First of all, we won&#8217;t be editing Mage_CatalogRule_Model_Mysql4_Rule, but instead create a new model that is a replacement for the observer that started it all: Mage_CatalogRule_Model_Observer.</p>
<p>Instead of applying all rules to the product, I will first check which rules actually apply to the product, and then only apply those. Now, there&#8217;s one thing to keep in mind here: If all rules are valid, the catalogrule_product_price table will never get reset for the specific product, so this we&#8217;ll have to do first. After that, when we apply the right rules, it will get filled up and nothing will be lost again.</p>
<p>Here&#8217;s my finished code with comments:</p>
<pre class="brush: php; title: ; notranslate">
public function applyAllRulesOnProduct($observer) {
		$product = $observer-&gt;getEvent ()-&gt;getProduct ();
		/* @var $product Mage_Catalog_Model_Product */

		if ($product-&gt;getIsMassupdate ()) {
			return;
		}

		$productWebsiteIds = $product-&gt;getWebsiteIds ();

		$rules = Mage::getModel ( 'catalogrule/rule' )-&gt;getCollection ()-&gt;addFieldToFilter ( 'is_active', 1 );

		// WOUTER - WE ARE DOING THIS DIFFERENTLY, BECAUSE MAGENTO'S OWN CODE DOESN'T WORK

		// 1. Delete all rule prices
		$write = Mage::getSingleton ( 'core/resource' )-&gt;getConnection ( 'core_write' );
		/* @var $write Varien_Db_Adapter_Pdo_Mysql */

		$tableName = Mage::getSingleton ( 'core/resource' )-&gt;getTableName ( 'catalogrule/rule_product_price' );
		$write-&gt;delete ( $tableName, array ($write-&gt;quoteInto ( 'product_id=?', $product-&gt;getId() ) ) );

		foreach ( $rules as $rule ) {
			/* @var $rule Mage_CatalogRule_Model_Mysql4_Rule */

			// 2. Find the rules that are valid
			if ($rule-&gt;getConditions ()-&gt;validate ( $product )) {

				// 3. Apply the valid rules
				if (! is_array ( $rule-&gt;getWebsiteIds () )) {
					$ruleWebsiteIds = ( array ) explode ( ',', $rule-&gt;getWebsiteIds () );
				} else {
					$ruleWebsiteIds = $rule-&gt;getWebsiteIds ();
				}
				$websiteIds = array_intersect ( $productWebsiteIds, $ruleWebsiteIds );
				$rule-&gt;applyToProduct ( $product, $websiteIds );
			}
		}
		return $this;
	}
</pre>
<p>So, that&#8217;s it. You can now save products and have the right rules applied immediately!</p>
<p>Liked my solution or need further help? I&#8217;m free for hire.</p>
]]></content:encoded>
			<wfw:commentRss>http://allwebsites.be/en/catalog-rules-dont-always-get-applied-when-saving-a-product-in-magento-1-4-2-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento 1.4.2.0 doesn&#8217;t show general and other tabs in adminhtml when creating or editing a product</title>
		<link>http://allwebsites.be/en/magento-1-4-2-0-doesnt-show-general-and-other-tabs-in-adminhtml-when-creating-or-editing-a-product/</link>
		<comments>http://allwebsites.be/en/magento-1-4-2-0-doesnt-show-general-and-other-tabs-in-adminhtml-when-creating-or-editing-a-product/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 17:07:11 +0000</pubDate>
		<dc:creator>Wouter Samaey</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento 1.4.2.0]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://allwebsites.be/?p=1415</guid>
		<description><![CDATA[Magento 1.4.2.0 breaks the edit tabs general, prices, etc when creating or editing a product. Here's a breakdown of the problem.]]></description>
			<content:encoded><![CDATA[<p>When I was upgrading Magento from 1.4.1.1 to 1.4.2.0 I encountered a problem that made several edit tabs unavailable when creating or modifying a product in adminhtml. Tabs like &#8220;general&#8221;, &#8220;prices&#8221;, etc were all gone. The first remaining tab was &#8220;stock&#8221; and some others that have their own Tab classes for rendering.</p>
<p><img class="size-large wp-image-1417 alignnone" title="Magento-missing-tabs" src="http://allwebsites.be/files/2010/12/Magento-missing-tabs-692x242.jpg" alt="Magento 1.4.2.0 missing tabs while editing product" width="692" height="242" /></p>
<h2>The Problem</h2>
<p>When digging deeper into the problem, I discovered the problem was caused in Mage_Eav_Model_Config::getEntityAttributeCodes($entityType, $object=null), around line 475.</p>
<p>The code in 1.4.2.0 reads:</p>
<pre class="brush: php; title: ; notranslate">
$attributesInfo = Mage::getResourceModel($entityType-&amp;gt;getEntityAttributeCollection())
-&gt;setEntityTypeFilter($entityType)
-&gt;setAttributeSetFilter($attributeSetId)
//                -&gt;addSetInfo()
-&gt;addStoreLabel($storeId)
-&gt;getData();
</pre>
<p>This results in an empty array for $attributesInfo.</p>
<p>In 1.4.1.1 the code was working and returned an array of over 80 elements (in my setup). The old code was:</p>
<pre class="brush: php; title: ; notranslate">
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
-&gt;setEntityTypeFilter($entityType)
-&gt;setAttributeSetFilter($attributeSetId)
// -&gt;addSetInfo()
-&gt;addStoreLabel($storeId)
-&gt;getData();
</pre>
<p>Basically it comes down to the argument for the getResourceModel() function. The argument used to be &#8220;eav/entity_attribute_collection&#8221;, but has now been swapped for a function that returns the value &#8220;catalog/category_attribute_collection&#8221;.</p>
<p>I&#8217;m not sure if this is an evolutionary move Magento is making, or a glitch in the upgrade procedure.</p>
<h2>The Solution</h2>
<p>This new function getEntityAttributeCollection() is used a couple of times more in the same file, but never anywhere else. Instead of swapping out the new code for the old, you should take care of the problem at the core: in your database!</p>
<p>Take a look at the eav_entity_type table and make sure the record for &#8220;catalog/product&#8221; has the value &#8220;catalog/product_attribute_collection&#8221; instead of &#8220;catalog/category_attribute_collection&#8221;. If you change this, there is no need to change any core files!</p>
<p>Did this work for you? Let us know!</p>
]]></content:encoded>
			<wfw:commentRss>http://allwebsites.be/en/magento-1-4-2-0-doesnt-show-general-and-other-tabs-in-adminhtml-when-creating-or-editing-a-product/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up an environment for PHP development</title>
		<link>http://allwebsites.be/en/setting-up-an-environment-for-php-development/</link>
		<comments>http://allwebsites.be/en/setting-up-an-environment-for-php-development/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 12:32:24 +0000</pubDate>
		<dc:creator>Wouter Samaey</dc:creator>
				<category><![CDATA[Niet ingedeeld]]></category>

		<guid isPermaLink="false">http://www.woutersamaey.be/?p=25</guid>
		<description><![CDATA[Over the last 2 years I&#8217;ve been surprised many times when meeting other people working with PHP. Many of them were actually working with programs like Dreamweaver or even notepad or vim. It struck me as odd, that these people had no idea of the tools available out there and the benefits they offer over [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last 2 years I&#8217;ve been surprised many times when meeting other people working with PHP. Many of them were actually working with programs like Dreamweaver or even notepad or vim. It struck me as odd, that these people had no idea of the tools available out there and the benefits they offer over basic text editors, beyond code highlighting.</p>
<p>For this reason, I will explain how my system is set up and what practices I have developed over the years. This article is targeted at PHP hobbyists and beginners.</p>
<h3>Development Server</h3>
<p>First of all we require a local webserver. PHP is a server-side scripting language, which means that the </p>
]]></content:encoded>
			<wfw:commentRss>http://allwebsites.be/en/setting-up-an-environment-for-php-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans is not breaking at breakpoints using Xdebug</title>
		<link>http://allwebsites.be/en/netbeans-is-not-breaking-at-breakpoints-using-xdebug/</link>
		<comments>http://allwebsites.be/en/netbeans-is-not-breaking-at-breakpoints-using-xdebug/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 23:32:35 +0000</pubDate>
		<dc:creator>Wouter Samaey</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xdebug]]></category>

		<guid isPermaLink="false">http://www.woutersamaey.be/?p=4</guid>
		<description><![CDATA[I recently settled on Xdebug and Netbeans 6.8 for my PHP development work after using Zend Studio for 1.5 years. I just got fed up by the way the debugger tends to misbehave on big projects (any many other small bugs). One thing I did discover with the Netbeans and Xdebug combo was that for [...]]]></description>
			<content:encoded><![CDATA[<p>I recently settled on <a href="http://xdebug.org/">Xdebug</a> and <a href="http://netbeans.org/">Netbeans 6.8</a> for my PHP development work after using Zend Studio for 1.5 years. I just got fed up by the way the debugger tends to misbehave on big projects (any many other small bugs).</p>
<p>One thing I did discover with the Netbeans and Xdebug combo was that for some reason it didn&#8217;t break on breakpoints set in Netbeans. While trying to figure it out I did notice that Xdebug was loaded and actually working (I tried <a href="http://www.bluestatic.org/software/macgdbp/">MacGDBp</a>, a simple debugger GUI on Mac, and that did work), but for some reason Netbeans didn&#8217;t break.</p>
<p>I read many guides and instructions online, but the answer turned out to be really simple (but little tricky to figure out).</p>
<h3>Loading the module correctly</h3>
<p>xdebug.so (or xdebug.dll on Windows) should be loaded using:</p>
<div class="codesnip-container" >
<div class="ini codesnip"><span class="re1">zend_extension</span> <span class="sy0">=</span><span class="re2"> /path/to/xdebug.so</span></div>
</div>
<p>And <em>not</em> using:</p>
<div class="codesnip-container" >
<div class="ini codesnip"><span class="re1">extension</span> <span class="sy0">=</span><span class="re2"> /path/to/xdebug.so</span></div>
</div>
<p>If you do use this way, you will get the module to load, and it will show up in phpinfo(), but Netbeans will not break on your breakpoints! So, switch to zend_extension. This has to do with the way xdebug loads, and is essential.</p>
<h3>Making sure you have the Zend Extension Manager</h3>
<p>This zend_extension directive relies on the Zend Extension Manager, which comes bundled with many all-in-one development packages (like MAMP). However, it did not came bundled with XAMPP on Mac. So, I took ZendExtensionManager.so from <a href="http://www.mamp.info">MAMP</a> and put it in my PHP extension folder.</p>
<p>ZendExtensionManager.so should be loaded using the regular extension directive (obviously):</p>
<div class="codesnip-container" >
<div class="ini codesnip"><span class="re1">extension</span> <span class="sy0">=</span><span class="re2"> ZendExtensionManager.so</span></div>
</div>
<p>After this, you will be able to use the zend_extension directive.</p>
<h3>Zend Optimizer doesn&#8217;t like Xdebug</h3>
<p>If you already had the Zend Extension Manager, you will most likely also have the Zend Optimizer. You&#8217;ll probably need to turn it off. I didn&#8217;t try to get both to work at the same time, but I was informed that the 2 don&#8217;t go together.</p>
<h3>Configure Xdebug correctly</h3>
<p>This is the easy part. Netbeans only requires these 5 lines of configuration. While Netbeans itself will tell you to add the first 4 lines, I did figure out the 5th line is also needed.</p>
<div class="codesnip-container" >
<div class="ini codesnip">xdebug.remote_enable <span class="sy0">=</span><span class="re2"> on</span><br />
xdebug.remote_handler <span class="sy0">=</span><span class="re2"> dbgp</span><br />
xdebug.remote_host <span class="sy0">=</span><span class="re2"> localhost</span><br />
xdebug.remote_port <span class="sy0">=</span><span class="re2"> 9000</span><br />
xdebug.idekey<span class="sy0">=</span><span class="st0">&quot;netbeans-xdebug&quot;</span></div>
</div>
<p>I also added these 2 lines, but they are optional. The log is actually quite helpful for figuring out problems in the future.</p>
<div class="codesnip-container" >
<div class="ini codesnip">xdebug.remote_mode<span class="sy0">=</span><span class="re2">req</span><br />
xdebug.remote_log <span class="sy0">=</span> <span class="st0">&quot;/Applications/XAMPP/xamppfiles/logs/xdebug_remote.log&quot;</span></div>
</div>
<p>Use phpinfo() to check that the settings are actually applied.</p>
<h3>Check your phpinfo()</h3>
<p>Now, you should see Xdebug being loaded as a Zend extension, like demonstrated below:</p>
<p><a href="http://www.woutersamaey.be/wp-content/uploads/2010/01/xdebug-loaded-as-zend-extension.png"><img class="alignnone size-full wp-image-5" src="http://www.woutersamaey.be/wp-content/uploads/2010/01/xdebug-loaded-as-zend-extension.png" alt="phpinfo() reports that Xdebug is loaded as a Zend Extension" width="606" height="85" /></a></p>
<p>You will also see it loaded further down the phpinfo() page:</p>
<p><a href="http://www.woutersamaey.be/wp-content/uploads/2010/01/xdebug-module-loaded.png"><img class="alignnone size-full wp-image-6" src="http://www.woutersamaey.be/wp-content/uploads/2010/01/xdebug-module-loaded.png" alt="xdebug module loaded in phpinfo()" width="608" height="287" /></a></p>
<h3>Conclusion</h3>
<p>So, I hope this may have helped you. If it didn&#8217;t, leave a message and I&#8217;ll check it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://allwebsites.be/en/netbeans-is-not-breaking-at-breakpoints-using-xdebug/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Obtained Zend PHP5 Certified status</title>
		<link>http://allwebsites.be/en/obtained-zend-php5-certified-status/</link>
		<comments>http://allwebsites.be/en/obtained-zend-php5-certified-status/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 20:45:04 +0000</pubDate>
		<dc:creator>Wouter Samaey</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.woutersamaey.be/?p=141</guid>
		<description><![CDATA[After 1 to 2 months of study and many more years of PHP practise before that, I finally reached Zend PHP5 Certified status. The exam was arranged at my old school, and hardly took an hour. Still, there were some pretty tough questions, but I got it well covered. Still, studying the certification book will [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.zend.com/en/store/education/certification/yellow-pages.php#show-ClientCandidateID=ZEND007417"><img src="http://www.woutersamaey.be/wp-content/uploads/2008/04/php5-zce-logo-new.jpg" alt="Zend Certified PHP5 Engineer" width="130" height="121" class="alignleft size-full wp-image-143" /></a></p>
<p>After 1 to 2 months of study and many more years of PHP practise before that, I finally reached Zend PHP5 Certified status. The exam was arranged at my old school, and hardly took an hour. Still, there were some pretty tough questions, but I got it well covered. Still, studying the certification book will only get you 50% score, which isn&#8217;t enough. Thankfully I know the PHP manual pretty thorough, as it has been my main resource since the day I started. Woohoo!</p>
<p>So, I&#8217;m in the Zend Yellow Pages as of now, and here&#8217;s the <a href="http://www.zend.com/en/store/education/certification/yellow-pages.php#show-ClientCandidateID=ZEND007417">proof</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://allwebsites.be/en/obtained-zend-php5-certified-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc

Served from: www.ad-ministerie.be @ 2012-02-22 23:20:22 -->
