Programmatically create order statuses in Magento

If you want to create new order statuses (not states) and assign them to a particular state you need to use the sales/order_status model. It’s pretty easy: $status = Mage::getModel(‘sales/order_status’); $status->setStatus(‘status_code’); $status->setLabel(‘status_label’); Then you can assign the state with the assignState method: $status->assignState(‘processing’); $status->save();

What’s new in Magento 1.7 alpha?

People from bloggento have written a great article about what’s new in Magento 1.7 alpha. Let’s take a look! Forms Captcha Captcha is a security system for forms that basically prevents spam. The «one» that is filling the form has to prove that he or she is a human. Captcha helps with that. Now we’ll find this option inside: System » Configuration » Client » Configuration client Price per client group From now on it’s Read more…

How to set tier prices programmatically in Magento

Working with tier prices programmatically in Magento is somewhat tricky. I found a couple of annoying bugs or behaviors that really got me stuck. I’ll speak about that at the end of this post. Update: Our colleague Josh found how to solve this issue by rewriting a core module. Take a look at that solution in StackOverflow. The solution below is still valid and you can use it anyway! Setting tier prices programmatically In order to Read more…

Get customer product alert subscriptions list in Magento

Some things are easy, some things are not. This one is easy-peasy. If you want to get the product list that a customer has been subscribed to (price or stock alert), you need to use the productalert model. Product stock alert list $customer_id = Mage::getSingleton(‘customer/session’)->getCustomer()->getId(); $customer_stock_alerts = Mage::getModel(‘productalert/stock’) ->getCollection() ->addFieldToFilter(‘customer_id’, $customer_id); foreach ( $customer_stock_alerts as $alert ) { echo $alert->getProductId(); } Product price alert list $customer_id = Mage::getSingleton(‘customer/session’)->getCustomer()->getId(); $customer_price_alerts = Mage::getModel(‘productalert/price’) ->getCollection() ->addFieldToFilter(‘customer_id’, $customer_id); foreach Read more…

Multiple newsletter lists in Magento

The best extension I’ve run into related to multi-newsletter (or simply newsletter groups) is the following one: Newsletter groups It’s free and works like a charm. It allows us to easily create newsletter groups from the backend (Newsletters » Newsletters groups) and then modifies the newsletter blocks on the website to add more checkboxes, so the customers can check on the groups they want to sign up. After that, we can send/exports newsletters filtering by these Read more…

Adding a category attribute in Magento

I was looking for a code in order to create category attributes in Magento and found a post from Mukesh Chapagain where he explains in a really easy way how to do so. But it didn’t work for me. I’m supposing that the problem is the way how we call the installer in the mysql php file. So I want to explain here, step by step, how I did to make it work: Create the Read more…

Fixing reindexing price errors in Magento

I’ve upgraded a couple of Magento CE (1.4) to Magento EE (1.11) using the traditional (and effective) way. But I found that there was an important issue when reindexing prices that prevented Magento from doing it.

Reading this post on Magento Boards I found that the problem (in my case) was related to an error with the catalog_product_entity_tier_price table where some of the entries were related to products that didn’t exist anymore. This was the actual error and when trying to reindex product prices, Magento would throw this message:

Getting (and setting) a custom product price (per customer) in Magento

The current project I’m working on has something special: each client has its own price, but this price is not in Magento but in an Oracle DB. Every client on the website has a client id related to the Oracle DB, and in the Oracle DB there is a discount that is different for each client. The possibility of adding all these price rules for each client in Magento is discarded. Then, the solution is Read more…