MySQL server has gone away error fix for Magento

Today I wanted to test a tiny shell script, that didn’t do such magic stuff. It only generates a few websites, stores and storeviews and associates approximately 200 products to 4 websites. When I ran it locally I had no problems at all. But on the staging server I got the following error message when […]

Associate products to all websites more performant

Recently I had to associate all products of a shop to newly created websites in a setup shell script (Associate products to all websites). This could have been implemented like that: <?php /** * Associates products to the newly created websites */ private function _associateProducts() { $aWebsiteIDs = Mage::getModel(‘core/website’) ->getResourceCollection() ->getAllIds(); //remove default website array_shift($aWebsiteIDs); // […]

Enable https behind loadbalancers for Contao CMS

Recently I had the pleasure to setup Contao (https://contao.org/) in the Amazon cloud (AWS – Elastic Beanstalk). Therefore I had to enable HTTPS behind loadbalancers. The problem was, that the AWS-Loadbalancer is the SSL Endpoint / SSL Terminator in an AWS Beanstalk – architecture. Contao didn’t recognize, that it was running under HTTPS and therefore set the wrong […]

Formatted CSV output on Linux shell

If you want to output a CSV file on Linux shell, you could just open it with less, cat or nano (un-formatted CSV output): $> less mydummyfile.csv $> cat mydummyfile.csv $> nano mydummyfile.csv The problem with this approach is, that you will get an unformatted ugly chunk of characters like that: A much better way is it, […]

Get all attribute options

To get all attribute options from a Magento dropdown attribute (select field) you can use the following snippet: <?php $oAttibute = Mage::getModel(‘eav/config’)->getAttribute(Mage_Catalog_Model_Product::ENTITY, ‘sheldon_special’); $aOptions = $oAttibute->getSource()->getAllOptions(); var_dump($aOptions); That gives you an array like that: <?php $aOptions = {array} [6] 0 = {array} [2] label = “” value = “” 1 = {array} [2] label = […]

Syntax search engine SyntaxDB

Today I discovered a really nice syntax search engine for programming languages. You can search programming constructs like loops or conditions via an input field. You will get examples for the different programming languages. That’s pretty cool, if you are a cross language programmer like me, because sometimes it’s hard to remember each construct in the […]

Load product attributes more performant

Recently I had performance issues when importing several ten tausend products. The problem was, that I always used the “normal” product entity model to load attribute values. The following snippet shows, how to load product attributes directly instead. Therefore I use the product resource singleton. <?php $iProductId = $aChange[‘pid’]; $oItem = new Varien_Object; /** * […]