Magento Themes and Magento Extensions

Magento – the “read-only” community?

Posted on December 3rd, 2012 | Posted by admin

ntil recently I considered the Magento mostly as a “read-only” community. Especially when I started with my first Magento projects there wasn’t much information around. Every now and then Varien (later then Magento Inc.) published a new version. I checked what was new, tested our projects with it and used that version from then on. If we encountered some bugs we digged into the code. Usually spent lots of hours and energy to spot the bug and fix it, contact Magento support, waited a couple of days and got the answer, that this is a known bug. Usually their response contained an official “patch” that in most cases was very similar to how we’ve fixed that.

Almost every time I asked myself, how we could actually be the first ones stumbling over this issue. And Magento support proved: We weren’t.

Magento add Bestseller products by date range

Posted on December 2nd, 2012 | Posted by admin

Magento add Bestseller products by date range

Here is how to get a collection of products best sold in a given date range

03.$from = date("Y-m-d H:i:s", (time()-2592000));
04.$to = date("Y-m-d H:i:s", time());
06.$_productCollection= Mage::getResourceModel('reports/product_collection')
08.->addOrderedQty($from, $to, true)
09.->addAttributeToFilter('status', 1)
10.->setOrder('ordered_qty', 'desc')

Get Cart Quantity in Magento

Posted on December 1st, 2012 | Posted by admin

Get Cart Quantity in Magento

You can get the number of items currently in the cart using the following code.

$cart = Mage::getModel('checkout/cart')->getQuote()->getData();
echo (int)$cart['items_qty'];

However,if the cart is empty, writing only the above code will show error (Because $cart['items_qty'] is only set when there are items on the cart). For that you need to check if the value is set or not. Hence the total code will be like –

Programmatically Create Magento Product Packages

Posted on November 30th, 2012 | Posted by admin

On a recent project I had to write a piece of code which I thought I’d share with the Magento community in case it comes in useful for anyone. I have put all the code into one ‘add to cart’ controller below for the sake of simplicity, but you could break it up into separate methods to clean up the code a bit.

In a nutshell, all products on the site have a normal price and some have a package price. If they have a package price they are capable of being purchased with other products as part of a package deal, but only two at a time. Therefore these products had to be purchased as one product using the special prices as we can’t have customers adjusting the quantities of items added to the cart. Here’s the code in myPackageController.php broken up:


Posted on November 29th, 2012 | Posted by admin

The last couple of weeks I have been building an e-commerce website using open source software Magento. The most important factor about Magento is the ability to change absolutely anything in the code to suit your own requirements meaning anything is possible.

The one problem with this is the well-known steep learning curve that comes along with the software where even the simplest of tasks become hours worth of online investigation. The lack of one-to-one support results in the scouring of  forums, chat rooms and blog posts until you find your answer, which when people have their own problems to deal with, can mean that help is not top of anyone’s priority.