Hidden Secrets of Magento Price Rules
-
Upload
ivan-chepurnyi -
Category
Technology
-
view
18.777 -
download
1
description
Transcript of Hidden Secrets of Magento Price Rules
![Page 1: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/1.jpg)
Ivan Chepurnyi
Hidden Secrets of Magento Promotion Rules
![Page 2: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/2.jpg)
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
![Page 3: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/3.jpg)
Short Overview
• Price Calculation Basics• Catalog Rule vs Shopping Cart Rule• The Base of Promo Rules• How To Customize
![Page 4: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/4.jpg)
General Magento Price Types
Final Price• Based on Qty &
Customer Group • Calculated
Dynamically• Used in:
– Shopping Cart– Product View
Minimal Price• Based on Customer
Group• Calculated by
Indexer• Used in:
– Product List
![Page 5: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/5.jpg)
Minimal Price
It is just minimal variation of final price
![Page 6: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/6.jpg)
HOW IS CALCULATED FINAL PRICE?
![Page 7: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/7.jpg)
Final Price
Option Price 1
Minimal Base Price
Option Price 2
Option Price N
…
![Page 8: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/8.jpg)
Minimal Base Price
• Product Price• Tier Price• Group Price (CE1.7)• Special Price• Catalog Rule Price
Magento takes minimal value from the following calculated price variations.
![Page 9: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/9.jpg)
Option Price
• Configurable Product Options (If Product is Configurable)
• Custom Options
![Page 10: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/10.jpg)
PRICE RULESAnd finally
![Page 11: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/11.jpg)
Price Rules
• Easy way to set up discounts for a group of products
• Conditional Discounts Based on– Product Attributes– Customer Group– Shopping Cart Content
![Page 12: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/12.jpg)
Price Rule Types
Catalog Price Rules• Pre-applied• Affect Final Product
Price• Conditions only for
Product Attributes
Shopping Cart Price Rules• Applied on the fly• Affect Shopping Cart
Totals• Various Set of
Conditions– Product Sub-select– Address Match– Advanced Customer
Targeting
![Page 13: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/13.jpg)
Use Cases
Catalog Price Rules• Season Sale
Discount• Customer Group
Discount• Discount on Product
Attribute Match
Shopping Cart Price Rule• Buy X Get Y Free
Discount• Free Shipping on
Particular Items• Special Discount for
Loyal Customers (in conjunction with Customer Segment)
![Page 14: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/14.jpg)
MAGE_RULE MODULEAnd finally some code
![Page 15: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/15.jpg)
Mage_Rule Module
Rule ModelMage_Rule_Model_Rule
ConditionMage_Rule_Model_Condition_Abstract
ActionMage_Rule_Model_Action_Abstract
![Page 16: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/16.jpg)
Rule Model
Contains such information• Conditions set• Actions set• Takes care about matched object
![Page 17: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/17.jpg)
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
![Page 18: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/18.jpg)
Action Model
• Supposed to be flexible list of actions that should be performed
• Currently is not used in the system
![Page 19: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/19.jpg)
Specific Implementations
Magento Community Edition• Mage_CatalogRule• Mage_SalesRule
Magento Enterprise Edition• Enterprise_TargetRule• Enterprise_CustomerSegment
![Page 20: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/20.jpg)
CUSTOMIZATIONDoing Simple
![Page 21: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/21.jpg)
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
![Page 22: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/22.jpg)
Properties Initialization
protected function _initProperties() { $this->_properties = array( ‘attribute_' => array( 'label' => ‘Some Field Name’, 'type' => 'select', 'data_path' => ’data/path’, 'options' => array() ) );}
![Page 23: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/23.jpg)
Property Types
Types:• string• numeric• date• select• multiselect
![Page 24: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/24.jpg)
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());
![Page 25: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/25.jpg)
Thank You!
![Page 26: Hidden Secrets of Magento Price Rules](https://reader033.fdocuments.net/reader033/viewer/2022052522/554dd972b4c905cc0e8b4e7c/html5/thumbnails/26.jpg)
Test Driven Development Training Course in Berlin, 09-10 Jan
http://bit.ly/QeOmia