0

I would like to schedule the shipping methods activation/deactivation programmatically.

I've created job correctly but I don't know how to load the shipping method object to call (if it exists) ->setData('is_active', $status) and to save it, as for cms block.

CMS Block Example:

Mage::getModel('cms/block')->load($blocks_to_active[$row])->setData('is_active', $status)->save();

2 Answers 2

0

I solved it. It was easier than I thought.

The shipping methods status is saved in core_config_data table (where path like 'carriers%active'); so I don't need to load a "shipping method" object. Just use Mage::getConfig()->saveConfig() Magento function.

In my case:

For Activation

Mage::getConfig()->saveConfig('carriers/my_shipping_method/active', 1, 'default', 0);

For Deactivation

Mage::getConfig()->saveConfig('carriers/my_shipping_method/active', 0, 'default', 0); 
0

This is close, thank you. But selecting carriers%active gets you the carrier's active/inactive state, not each method.

UPS for example, has many methods (ups_01, ups_03...), which is what I was looking for and I thought your original question was asking that.

I was looking to target specific methods within a particular carrier. But you are right, the core_config is the place to do it.

The carriers/%/allowed_methods configuration values provide a comma-delimited list of allowed methods per carrier, if enabled. In this case, one would need to know the method codes beforehand to update this configuration value as needed. But you steered me in the right direction, so it saved me looking elsewhere. Nice.

Glad you figured out your own needs.

1
  • I'm happy to read your comment and to know my answer helped you. If you want, you could click on "This answer is useful" (upvote) button to help another people.
    – WaPoNe
    Commented Jan 4, 2017 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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