1

I want to change the amount of a specific sales rule via an instsall script.

This is my install code:

$inviterValue = "5";
$inviterId = Mage::getStoreConfig('xxx/bm_invitation_coupon_ids/inviter_coupon_id');
$inviteeValue = "15";
$inviteeId = Mage::getStoreConfig('xxx/bm_invitation_coupon_ids/invitee_coupon_id');

/** @var Bm_SalesRule_Model_Rule $couponsChange */
$couponsChange = Mage::getModel('salesrule/rule');
$couponsChange->load($inviterId)->setDiscountAmount($inviterValue)->save();

If I use this code in a phtml file, the change is applied. If I have this in my install-0.0.1.php, it does not.

Why and how could I fix it?

0

Based on my findings there are Mage::-Godclass operations that don't work on the sql install level.

If you need to receive XML data settings, you should use the data-way to do operations based on a higher level of execution in Magento.

Data structure:

- Vendor
  - Modulename
    - data
      - vendor_modulename_setup
        - data-install-0.0.1.php
    - sql
      - vendor_modulename_setup
        - install-0.0.1.php

Also, the data install does not work without resource node in the config.xml and a install-script.

In data-install-0.0.1.php you can access highlevel Mage Functions such as Mage::getStoreConfig.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.