Hot answers tagged

13

To add a conditional field to the default model (and further utilize it for validating purposes), you will need to create a new model (or modify the existing one) that contains these fields. app/code/Vendor/Rules/Setup/InstallSchema.php <?php namespace Vendor\Rules\Setup; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Setup\...


8

finally I found the solution. /*Controller code */ $modelRule = $this->_objectManager->create('NameSpace\ModuleName\Model\Rule'); $data = $this->prepareData($data); $modelRule->loadPost($data); $productIds = $modelRule->getListProductIds(); protected function prepareData($data) { ...


7

Recently I had the same problem when I was testing a new price rule for our project. And the reason of my headache was that I did not notice that every time when you create a new rule or edit some of the existing rules - you should press "Apply Rules" button to make Magento know about your rule changes.


7

Making sure to hit "Apply Rules" is not always enough. I recently discovered that if cron is not set up properly, at some point in the future, the rules will not be applied. I was unable to really nail down when the rules stopped working. In my case I had a handful of rules that are applied based on customer group (wholesale). Check the cron_schedule ...


6

Thanks Ankit Shah, Solution here : https://magento.stackexchange.com/a/141422/43576 "As of version 2.1.1 this is a configuration item. In Stores > Configuration > Customers > Customer Configuration > Password Options there's some options like Password Length and Number of Required Character Classes. Not sure at which version this was introduced but if you ...


4

Using UI component for Magento2.1 <fieldset name="conditions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Conditions</item> <item name="collapsible" xsi:type="boolean">true</item> <item name="...


4

Finally i have solve this issue. Now you can use this code and i hope it's also beneficial for you guys. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $fixtureTaxRule = $objectManager->create(\Magento\Tax\Model\Calculation\Rule::class); $fixtureTaxRule->setCode("Test"); $fixtureTaxRule->setPriority(0); $fixtureTaxRule-&...


4

You need to make your custom Conditions.php and just replace $formName argument of addTabToForm function with your form name. you are using Magento core file and it's adding the selected value of conditions section in sales_rule_form form Updated code : eg. function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $formName = 'example_form'...


3

Magento does not take into account custom options when calculate shopping cart rules unless you have an extension for this. We do the following trick: rewrite class Mage_SalesRule_Model_Rule_Condition_Product and add 2 new custom attributes 'Custom Options SKU' and 'Custom Options Values' Then get options to validate as $options = $product->...


3

There aren't many ways to promote product diversity - they have to be set up for specific category pairings. If you have a limited number of categories you may be able to set up enough combinations to apply to a good portion of your catalog. See this example: Set up multiple rules In rule 1, set Product Attribute Combination so that it applies to 1 or ...


3

I'm guessing you're using Magento CE? This is not possible by default. although I never used the extension Aitoc Advanced Permissions apparently does allow you to do this without the need for coding.


3

Theres a really handy event for disabling and enabling payment methods on the fly. Add the following into your config.xml section <payment_method_is_active> <observers> <preorder_payment> <class>your_module/observers</class> <method>invoiceOnly</method> </...


3

Check if the job gets scheduled You can do this by either checking the database or install this extension: Aoe_Scheduler Test if the job works Create a php script run_my_rules.php and put in there only the content for the function: dailyCatalogUpdate then run that from the console. See what is happening.


3

Shopping Cart rules are carried over the cart. 2 options here : 1°) your rules are not applied correctly 2°) In the cart template you show price and not final_price of the product. Which version are you using ?


3

We can try: /** @var \Magento\SalesRule\Model\Rule $rule **/ $rule->load($ruleId); $isActive = $rule->getIsActive(); $fromDate = $rule->getFromDate(); $toDate = $rule->getToDate(); $label = $rule->getStoreLabels(); Or with API: /** @var \Magento\SalesRule\Api\RuleRepositoryInterface $rule **/ $rule->getById($ruleId); $isActive = $rule-&...


3

It would be great if you provide more information about your rules (priority etc). Rule 1 (15%) example screenshot https://goo.gl/ohGFFY Rule 2 (10%) example screenshot https://goo.gl/MwA3ZY If these rules are applied, and user buy Category A 1 product and Category B 1 Product, the discount is 10% https://goo.gl/xZrzdM


3

Hey there are two ways to do it 1.you can create a rule for this in which you need to define that if you added a product of 10$ then give 5$ off this is the easiest way to do it or you can give off in terms of how much percent you want to give off i recommend this approach to you.you can create cart rule from admin. 2.You have to manipulate the cart ...


2

Both shopping cart price rules and catalog price rules will apply to the product prices as they are used in the cart. The difference between the two is a shopping cart price rule is a discount that only shows once the item is in the cart, typically based on criteria which the line items in the cart meet. Catalog price rules are changes to the products in the ...


2

I think the problem is not in the rule conditions itself. It's in the way prices are displayed and calculated by Magento for configurable products. The price of the configurable product is always leading unless you specify different price on the Associated Products tab. If you use a grouped product this would become possible, because they rely more on the ...


2

You need to make your custom attribute available for the rules. Go to Catalog->Attributes->Manage attributes, edit your attribute and set the field Used for promo rules to yes. Reindex everything and your are done.


2

Can't you just do like so?: I tested it, seems to work on my system.. This one only applies discount on items in the specified range:


2

I was digging through this today and it's not easy to untangle. The way smart categories have been designed did not take into account any easy way for their creation programmatically via a migration script. The merchandiser data is completely compartmentalized from the category model and there are observers which listen for category saves in the admin and ...


2

Jamie, You are touching very silly part of Magento checkout, those are recurring payments. Magento has two types of totals calculation in the system: Normal Flow All the regular total collectors within Magento use getAllNonNominalItems() method in order to retrieve address items. Only during this flow Magento has Discount total, that is responsible for ...


2

Try something like code below, it should work correctly for tier prices and catalog price rules. /* @var $item Mage_Sales_Model_Quote_Item */ $item = Mage::getModel('sales/quote_item'); $qty = 3; $product = /* load product you want to get price for */; $item->setProduct($product); $item->setQty($qty); $item->setQuote(/* ...


2

So the problem is in the getOperatorCondition() in app/code/core/Mage/Rule/Model/Resource/Rule/Condition/SqlBuilder.php case '!{}': if (preg_match('/^.*(category_id)$/', $field) && is_array($value)) { $selectOperator = ' IN (?)'; } else { $selectOperator = ' LIKE ?'; } ...


2

There is no standard feature. For such a rule you should use the ANY type in conditions: In case you want to extend the standard condition model, then you should do the rewrite and add the appropriate condition like this: In class where rewriting Mage_SalesRule_Model_Rule_Condition_Address: public function loadAttributeOptions() { $attributes = parent:...


2

In your case, you need to create a custom theme. You should read more here: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/theme-create.html Put the validation rule in your custom theme with following path: app/design/frontend/Package/themename/Magento_Ui/web/js/lib/validation/rules.js


2

The conditions are the rules that must be met for this promotion to apply. The actions are the rules that govern what changes are made once the conditions are met and to which products. Below is just a brief example trying to show the difference. Example: Spend over $100 and get 10% off any shoes you buy. The conditions here will be: If subtotal is ...


2

You need write your custom module and you have to use this event (sales_quote_item_qty_set_after). in this event you need to - check current logged user and get all items that the customer purchanesed during current month. - check the QTY of your product, and if the qty is excedded the maximum qty, you need to throw expection throw new \Magento\Framework\...


Only top voted, non community-wiki answers of a minimum length are eligible