Magento 1 Posts Archive

How I Handle Modules In Magento

Posted On: Aug 29, 2015 by Josh Pennington
When I was learning how to use Magento back in 2010, everything was taught to be placed in a separate module. This made sense. You want your code to be modular so that you can easily move it from one installation to another and most of the people implementing Magento probably are doing work for multiple instances of Magento. However, I work for a single company and we run a single instance of Magento. Does...

One Way To Fix Add to Cart Being Slow In Magento

Posted On: Sep 15, 2011 by Josh Pennington
Today I was finally able to fix a pretty significant issue we were seeing at work. Over the past few weeks (really probably the last 6-8 weeks but it really showed its ugly head in the last 7 to 10 days) the time it was taking to add a product to cart was taking an incredibly long time (like 30 – 90 seconds). Obviously this can absolutely destroy conversion. The problem did not just stop...

Have Your Magento Caches Update Themselves

Posted On: Mar 19, 2011 by Josh Pennington
Magento has a lot of caches. They are (in my opinion) the biggest reason Magento is usable as a platform (If you think Magento runs slowly now – turn them off for a little bit). One thing that I as a programmer find odd is that the caches in Magento are intelligent enough to flag themselves as invalidated, however they generally require that they be refreshed by hand. This can be especially irritating when you...

An Overview of Magento’s Get and Set Methods

Posted On: Feb 15, 2011 by Josh Pennington
Magento handles its get and set methods in a way that if you do not understand how it works it can be confusing to you. In the beginning of this article you have to take a leap of faith and believe in magic. In Magento you can take nearly any model and get all the information about it with a simple function call. See the example below: $product = Mage::getModel('catalog/product')->load(1500); print_r($product->debug()); This code will return...

Get All Sale Products From A Category in Magento

Posted On: Feb 8, 2011 by Josh Pennington
I recently was tasked with creating a landing page that took all the products that were on sale in a particular category. At first this seemed like a challenge because I was not sure how to get a collection of products from a particular category. What I discovered that you can do is load a category model and then get a product collection and then continue to filter it down until you have the products...

When Reindexing in Magento Fails, Use The Command Line

Posted On: Feb 6, 2011 by Josh Pennington
One of the things that you have to get used to when running Magento is dealing with the indexes that it relies on. Usually you can do this from the admin panel by going to System -> Index Management. When indexing fails from the admin panel you get a message saying that it failed with no reason why it failed. Now in most cases you cannot ignore this. You may find that most (if not...

Set All Your Magento Categories to is_anchor

Posted On: Feb 5, 2011 by Josh Pennington
I recently was tasked to set every category inside our Magento installation have its is_anchor attribute set to true. We have over 600 categories so it would be a huge task to do this by hand so I put together a quick script that did this in less than a minute. error_reporting(E_ALL); ini_set('display_errors', '1'); // Load Up Magento Core define('MAGENTO', realpath('/path/to/magento')); require_once(MAGENTO . '/app/Mage.php'); $app = Mage::app(); $categories = Mage::getModel('catalog/category') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('is_anchor', 0) ->addAttributeToFilter('entity_id',...

About Josh

Web developer, tech junkie and Doctor Who aficionado. I've been professionally programming since 2007 but have been passionate about technology since childhood. Specialties include PHP and Magento, but am also experienced with Java, Ruby, Rails, C# and a many of other languages.

Around The Internet

Josh Pennington Facebook Josh Pennington Twitter Josh Pennington App.net Josh Pennington Google+ Josh Pennington LinkedIn Josh Pennington GitHub Josh Pennington Wanelo
profile for Josh Pennington on Stack Exchange, a network of free, community-driven Q&A sites

subscribe via RSS