Free Magento extension for Coupons Import

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone




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”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Magento: Check if coupon / sales rule is applicable for product

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

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:

// Sales Rule Id of the coupon we want to validate
$ruleId = 359;

// Id of Product we want to validate
$productId = 884;

/** @var Mage_SalesRule_Model_Rule $salesRule */
$salesRule = Mage::getModel('salesrule/rule')->load($ruleId);

/** @var Mage_Catalog_Model_Product $product */
$product = Mage::getModel('catalog/product')->load($productId);

$item = new Varien_Object();
$item->setProduct($product);

$isValid = (bool) $salesRule->getActions()->validate($item);

var_dump($isValid); // true OR false

Hope this helps!

Your thoughts?

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone