SlideShare a Scribd company logo
1 of 27
Ivan Chepurnyi

Hidden Secrets of Magento
     Promotion Rules
About Me
•   Devoted to Magento Platform since 2007
•   Ex Magento Core Team member
•   5+ Years of Magento Development Experience
•   Co-Founder & Technical Director at EcomDev
•   Providing Training Courses for Magento
    Developers
Short Overview
•   Price Calculation Basics
•   Catalog Rule vs Shopping Cart Rule
•   The Base of Promo Rules
•   How To Customize
General Magento Price Types
Final Price         Minimal Price
• Based on Qty &    • Based on Customer
  Customer Group      Group
• Calculated        • Calculated by
  Dynamically         Indexer
• Used in:          • Used in:
  – Shopping Cart     – Product List
  – Product View
Minimal Price


It is just minimal variation of
           final price
HOW IS CALCULATED FINAL
         PRICE?
Final Price

                Option Price 1

Minimal         Option Price 2
Base Price             …
                Option Price N
Minimal Base Price
•   Product Price         Magento takes
•   Tier Price            minimal value
•   Group Price (CE1.7)   from the following
•   Special Price         calculated price
•   Catalog Rule Price    variations.
Option Price
• Configurable Product Options
  (If Product is Configurable)

• Custom Options
And finally
PRICE RULES
Price Rules
• Easy way to set up discounts for a group
  of products

• Conditional Discounts Based on
  – Product Attributes
  – Customer Group
  – Shopping Cart Content
Price Rule Types
Catalog Price Rules      Shopping Cart Price Rules
• Pre-applied            • Applied on the fly
• Affect Final Product   • Affect Shopping Cart
  Price                    Totals
• Conditions only for    • Various Set of
  Product Attributes       Conditions
                           – Product Sub-select
                           – Address Match
                           – Advanced Customer
                             Targeting
Use Cases
Catalog Price Rules     Shopping Cart Price Rule
• Season Sale           • Buy X Get Y Free
  Discount                Discount
• Customer Group        • Free Shipping on
  Discount                Particular Items
• Discount on Product   • Special Discount for
  Attribute Match         Loyal Customers (in
                          conjunction with
                          Customer Segment)
And finally some code
MAGE_RULE MODULE
Mage_Rule Module

                        Condition
                        Mage_Rule_Model_Condition_Abstract



Rule Model
Mage_Rule_Model_Rule



                       Action
                       Mage_Rule_Model_Action_Abstract
Rule Model
Contains such information
• Conditions set
• Actions set
• Takes care about matched object
Condition Model
• Conditions can be complex or simple
• Matched against some Varien_Object
  (Product, Address, Customer, etc)
• All condition models extended from
 Mage_Rule_Model_Condition_Abstract
Action Model
• Supposed to be flexible list of actions that
  should be performed
• Currently is not used in the system
Specific Implementations
Magento Community Edition
• Mage_CatalogRule
• Mage_SalesRule

Magento Enterprise Edition
• Enterprise_TargetRule
• Enterprise_CustomerSegment
Doing Simple

CUSTOMIZATION
Create Custom Condition
1. Extend from this class in gist:
   https://gist.github.com/4136339

2. Implement _getLabel() method

3. Implement _initProperties() method

4. Add your condition to combine condition model for
   existing rule
Properties Initialization
protected function _initProperties()
{
    $this->_properties = array(
          ‘attribute_' => array(
               'label' => ‘Some Field Name’,
               'type' => 'select',
               'data_path' => ’data/path’,
               'options' => array()
          )
     );
}
Property Types
Types:
• string
• numeric
• date
• select
• multiselect
Adding To Combine Cond
For Sales Rules
• Add observer to salesrule_rule_condition_combine

• Add an array item to additional event property:

  $observer->getEvent()->setAdditional(
     Mage::getModel(‘yourcondition/model’)->getNewChildSelectOptions()
  );
Thank You!
Test Driven Development
Training Course in
Berlin, 09-10 Jan

http://bit.ly/QeOmia
Questions?
Twitter:
@IvanChepurnyi


Email:
ivan@ecomdev.org


Blog:
ecomdev.org

More Related Content

What's hot

Mini project report_on_online_shopping
Mini project report_on_online_shoppingMini project report_on_online_shopping
Mini project report_on_online_shopping
Sandeep Bittu
 

What's hot (20)

Magento 2 Design Patterns
Magento 2 Design PatternsMagento 2 Design Patterns
Magento 2 Design Patterns
 
Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2
 
Magento 2 Database Tables, Schema, Main tables for main features of Magento 2...
Magento 2 Database Tables, Schema, Main tables for main features of Magento 2...Magento 2 Database Tables, Schema, Main tables for main features of Magento 2...
Magento 2 Database Tables, Schema, Main tables for main features of Magento 2...
 
Final year project presentation
Final year project presentationFinal year project presentation
Final year project presentation
 
eCommerce with Magento
eCommerce with MagentoeCommerce with Magento
eCommerce with Magento
 
Mini project report_on_online_shopping
Mini project report_on_online_shoppingMini project report_on_online_shopping
Mini project report_on_online_shopping
 
Css
CssCss
Css
 
Magento 2
Magento 2Magento 2
Magento 2
 
Magento Product Recommendations powered by Adobe Sensei (AI)
Magento Product Recommendations powered by Adobe Sensei (AI)Magento Product Recommendations powered by Adobe Sensei (AI)
Magento Product Recommendations powered by Adobe Sensei (AI)
 
Magento Payment & Vault framework
Magento Payment & Vault frameworkMagento Payment & Vault framework
Magento Payment & Vault framework
 
Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2
 
Angular 2
Angular 2Angular 2
Angular 2
 
Meetup angular http client
Meetup angular http clientMeetup angular http client
Meetup angular http client
 
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading DataOptimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
 
Jquery
JqueryJquery
Jquery
 
Xhtml
XhtmlXhtml
Xhtml
 
jQuery
jQueryjQuery
jQuery
 
Srs group 4 v5 - esmart shopping
Srs group 4  v5 - esmart shoppingSrs group 4  v5 - esmart shopping
Srs group 4 v5 - esmart shopping
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 

Similar to Hidden Secrets of Magento Price Rules

Drupal Commerce Drupalhagen 2012
Drupal Commerce Drupalhagen 2012Drupal Commerce Drupalhagen 2012
Drupal Commerce Drupalhagen 2012
Jakob Torp
 
Ebay的自动化
Ebay的自动化Ebay的自动化
Ebay的自动化
yiditushe
 
Universal Analytics and Google Tag Manager - Superweek 2014
Universal Analytics and Google Tag Manager - Superweek 2014Universal Analytics and Google Tag Manager - Superweek 2014
Universal Analytics and Google Tag Manager - Superweek 2014
Yehoshua
 

Similar to Hidden Secrets of Magento Price Rules (20)

Merchandising & Miva Merchant 9 - Unlocking The Power Of Price Groups
Merchandising & Miva Merchant 9 - Unlocking The Power Of Price GroupsMerchandising & Miva Merchant 9 - Unlocking The Power Of Price Groups
Merchandising & Miva Merchant 9 - Unlocking The Power Of Price Groups
 
MivaCon Seattle - Merchandising & Miva Merchant 9: Unlocking the Power of Pri...
MivaCon Seattle - Merchandising & Miva Merchant 9: Unlocking the Power of Pri...MivaCon Seattle - Merchandising & Miva Merchant 9: Unlocking the Power of Pri...
MivaCon Seattle - Merchandising & Miva Merchant 9: Unlocking the Power of Pri...
 
Merchandising & miva merchant 9 – unlocking the power of price groups
Merchandising & miva merchant 9 – unlocking the power of price groupsMerchandising & miva merchant 9 – unlocking the power of price groups
Merchandising & miva merchant 9 – unlocking the power of price groups
 
Merchandising & Miva Merchant 9 - Price Groups
Merchandising & Miva Merchant 9 - Price GroupsMerchandising & Miva Merchant 9 - Price Groups
Merchandising & Miva Merchant 9 - Price Groups
 
PromoTale - a sale story
PromoTale - a sale storyPromoTale - a sale story
PromoTale - a sale story
 
Pricing
PricingPricing
Pricing
 
NANO MBA3 Category Management by kongkiat phanawadee
NANO MBA3 Category Management by kongkiat phanawadee NANO MBA3 Category Management by kongkiat phanawadee
NANO MBA3 Category Management by kongkiat phanawadee
 
Beyond Accuracy: Goal-Driven Recommender Systems Design
Beyond Accuracy: Goal-Driven Recommender Systems DesignBeyond Accuracy: Goal-Driven Recommender Systems Design
Beyond Accuracy: Goal-Driven Recommender Systems Design
 
Common design patterns in php
Common design patterns in phpCommon design patterns in php
Common design patterns in php
 
Drupal Commerce Drupalhagen 2012
Drupal Commerce Drupalhagen 2012Drupal Commerce Drupalhagen 2012
Drupal Commerce Drupalhagen 2012
 
Recommender systems
Recommender systems Recommender systems
Recommender systems
 
Pricing and the ceo may 2018 for xpeg
Pricing and the ceo may 2018 for xpegPricing and the ceo may 2018 for xpeg
Pricing and the ceo may 2018 for xpeg
 
Salesforce CPQ by yuvaraj
Salesforce CPQ by yuvarajSalesforce CPQ by yuvaraj
Salesforce CPQ by yuvaraj
 
Bmgt 411 chapter_12
Bmgt 411 chapter_12Bmgt 411 chapter_12
Bmgt 411 chapter_12
 
Webinar: Successful B2B Pricing Strategies with Magento
Webinar: Successful B2B Pricing Strategies with MagentoWebinar: Successful B2B Pricing Strategies with Magento
Webinar: Successful B2B Pricing Strategies with Magento
 
Webinar discover acquisio campaign automation algorithms
Webinar discover acquisio campaign automation algorithmsWebinar discover acquisio campaign automation algorithms
Webinar discover acquisio campaign automation algorithms
 
Ebay的自动化
Ebay的自动化Ebay的自动化
Ebay的自动化
 
Pricing for product managers vancouver nov 2017
Pricing for product managers vancouver nov 2017Pricing for product managers vancouver nov 2017
Pricing for product managers vancouver nov 2017
 
Universal Analytics and Google Tag Manager - Superweek 2014
Universal Analytics and Google Tag Manager - Superweek 2014Universal Analytics and Google Tag Manager - Superweek 2014
Universal Analytics and Google Tag Manager - Superweek 2014
 
Universal Analytics and Google Tag Manager
Universal Analytics and Google Tag ManagerUniversal Analytics and Google Tag Manager
Universal Analytics and Google Tag Manager
 

More from Ivan Chepurnyi (6)

How to import 1 million SKUs in under 10 minutes
How to import 1 million SKUs in under 10 minutesHow to import 1 million SKUs in under 10 minutes
How to import 1 million SKUs in under 10 minutes
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
 
Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Hidden Secrets of Magento Price Rules

  • 1. Ivan Chepurnyi Hidden Secrets of Magento Promotion Rules
  • 2. About Me • Devoted to Magento Platform since 2007 • Ex Magento Core Team member • 5+ Years of Magento Development Experience • Co-Founder & Technical Director at EcomDev • Providing Training Courses for Magento Developers
  • 3. Short Overview • Price Calculation Basics • Catalog Rule vs Shopping Cart Rule • The Base of Promo Rules • How To Customize
  • 4. General Magento Price Types Final Price Minimal Price • Based on Qty & • Based on Customer Customer Group Group • Calculated • Calculated by Dynamically Indexer • Used in: • Used in: – Shopping Cart – Product List – Product View
  • 5. Minimal Price It is just minimal variation of final price
  • 6. HOW IS CALCULATED FINAL PRICE?
  • 7. Final Price Option Price 1 Minimal Option Price 2 Base Price … Option Price N
  • 8. Minimal Base Price • Product Price Magento takes • Tier Price minimal value • Group Price (CE1.7) from the following • Special Price calculated price • Catalog Rule Price variations.
  • 9. Option Price • Configurable Product Options (If Product is Configurable) • Custom Options
  • 11. Price Rules • Easy way to set up discounts for a group of products • Conditional Discounts Based on – Product Attributes – Customer Group – Shopping Cart Content
  • 12. Price Rule Types Catalog Price Rules Shopping Cart Price Rules • Pre-applied • Applied on the fly • Affect Final Product • Affect Shopping Cart Price Totals • Conditions only for • Various Set of Product Attributes Conditions – Product Sub-select – Address Match – Advanced Customer Targeting
  • 13. Use Cases Catalog Price Rules Shopping Cart Price Rule • Season Sale • Buy X Get Y Free Discount Discount • Customer Group • Free Shipping on Discount Particular Items • Discount on Product • Special Discount for Attribute Match Loyal Customers (in conjunction with Customer Segment)
  • 14. And finally some code MAGE_RULE MODULE
  • 15. Mage_Rule Module Condition Mage_Rule_Model_Condition_Abstract Rule Model Mage_Rule_Model_Rule Action Mage_Rule_Model_Action_Abstract
  • 16. Rule Model Contains such information • Conditions set • Actions set • Takes care about matched object
  • 17. Condition Model • Conditions can be complex or simple • Matched against some Varien_Object (Product, Address, Customer, etc) • All condition models extended from Mage_Rule_Model_Condition_Abstract
  • 18. Action Model • Supposed to be flexible list of actions that should be performed • Currently is not used in the system
  • 19. Specific Implementations Magento Community Edition • Mage_CatalogRule • Mage_SalesRule Magento Enterprise Edition • Enterprise_TargetRule • Enterprise_CustomerSegment
  • 21. Create Custom Condition 1. Extend from this class in gist: https://gist.github.com/4136339 2. Implement _getLabel() method 3. Implement _initProperties() method 4. Add your condition to combine condition model for existing rule
  • 22. Properties Initialization protected function _initProperties() { $this->_properties = array( ‘attribute_' => array( 'label' => ‘Some Field Name’, 'type' => 'select', 'data_path' => ’data/path’, 'options' => array() ) ); }
  • 23. Property Types Types: • string • numeric • date • select • multiselect
  • 24. Adding To Combine Cond For Sales Rules • Add observer to salesrule_rule_condition_combine • Add an array item to additional event property: $observer->getEvent()->setAdditional( Mage::getModel(‘yourcondition/model’)->getNewChildSelectOptions() );
  • 26. Test Driven Development Training Course in Berlin, 09-10 Jan http://bit.ly/QeOmia