Category: Magento

Magento arrives with some really good functionality that allows store owners to create automatically generated coupons. Later those coupons can be sent to individual customers in marketing campaigns. Sometimes this strategy will not be insufficient in order to respond to certain business situations because the business case could require that the individual coupons be generated in third party system and later imported in Magento.

This weekend I’ve decided to do some programming for fun. I’ve developed a Magento extension that allows store owners to import coupons in Magento via Advanced Import/Profiles. So far the extension looks more like a proof of concept because it imports coupons that have very simple actions.

The coupons imported by my extension can be used in case you want have coupons for certain SKUs.

I’ve stuck to this basic functionality because describing coupon actions and conditions could lead to complicated data structure and right now I don’t have a clear idea how this data can be neatly described in CSV file. I believe that I would have a chance to develop more a flexible import once I get some feedback from people who’ve tried to utilise my extension.Continue reading “Free Magento extension for Coupons Import”→

Recently I had to implement something really interesting in Magento. My task was to check if coupon could be applied to product before the product is added in cart and coupon is submitted. I started implementing this validation on my own but after some digging in Magento core I found the best solution.

I constructed the snippet below after digging in Magento SalesRule module:

Last few weeks I was fighting with problem that partially broke Magento url indexer. Basically the url indexer was working but at certain point it was breaking. At this point I was getting exception and not all url rewrites were written to core_url_rewrite table. Everyday the problem was getting bigger and bigger because all new products contained “catalog/product/view/id” (I call those urls – “ugly” urls) but the desired urls suppose to be human readable and end with “.html”.

This issue could be reproduced only on live environment and in order to reproduce it locally I had to copy all catalog tables (catalog_*) and core_url_rewrite table from live to local environment.

Last few weeks I was searching for solution that allows me to reduce time of Magento database upgrade. In my case I had to upgrade very old Magento version to Magento CE 1.9.2.1 During my tests I found that database upgrade took around 6 hours. The reason was that I had very large database and of course there were a lot of database schema changes (e.g. removing a column of large table was taking ages). This meant that we could have at least 6 hours of down time during upgrade. This was a bit risky because we had limited time span and wanted to go live as soon as possible.

Let’s assume that as developer you are in following situation: You know a product id and you have to fetch single attribute value of a product which id you already know. For example let’s try to get color attribute of Magento product.

Question: How would you do it? Are you going to load the product or you would look for more efficient solutions in order to fetch only the attribute you are looking for?

Magento allows us to fetch product attribute in many ways and depending on the context we could choose one. I am definitely against loading entire product in case there are much more efficient solutions and the goal is to fetch single product attribute (not all product attributes).

I think that people choose the easy way because:

People read the first answer (which sometimes is not the most efficient) in StackOverflow but don’t check other answers.

There is a lack of Magento documentation.

Missing out of the box way how to accomplish the task.

There are many examples in Internet but they are not descriptive enough to explain what happens on background and how efficient they are.

About 2 weeks ago I worked on extension for Image Selector in Magento admin forms and I had to use base64 decode and encode functions. Basically Magento backend was sending me base64 encoded string and I had to to use base64 decode function in order to decode the data. I was lucky because Magento Core Team already had implemented such a functionality in JS files and those files were loaded in admin interface.

We have base64 functions in:

js/mage/adminhtml/tools.js (exists >= Magento CE 1.4 versions)

js/mage/adminhtml/hash.js (exists in older and current Magento CE versions)

Every day I get new ideas but unfortunately there is the time factor and my personal goals that don’t allow me to complete everything I want. At the beginning of this week I got interesting email from Ronald about something that was in my head since I’ve created Magento extension for custom cart validations. So this time I said to myself “Now is the moment!”:

I have been breaking my head over a way to enable Magento to sell products in multiples of X, but with any product combination possible. An example would be wine bottles. Any combination of wine bottles is possible, but checkout is only possible if the total quantity is a multiple of 6. If that rule is not validated, a message for the customer is displayed and checkout is disabled.

Would your method be the way to go here, and if so, can you point me in the right direction? Do you have a working example?