i want to get config data from current store not from default config so for example if i change Table rates title from "Table Rate" to "Something Else" in main webisite config and save it, i can see these changes also in Default store view and that is ok, but if i want to get this title "Something else" i always get title "Table Rates" i am using this code to check it:

$title = Mage::getStoreConfig('carriers/tablerate/title',Mage::app()->getStore()); 

and it always prints "Table Rate", i have also tried without 'Mage::app()->getStore())' cause i read there that "The getStoreConfig() method looks like return self::app()->getStore($store)->getConfig($path);, so it get the same if you don't pass the second param - 'Mage::app()->getStore()'." so can anyone tell me how to get config from main website not from default config?

p.s. i have my own shipping module with all config and cerrier and etc files, table rates is just a sample that is the same thing happens to the table rates also.

  • 1
    Where are you trying to execute this code? – user487772 May 8 '14 at 9:58
  • long story short, i have an observer that listens event <sales_order_shipment_save_before> (the same event when store admin push "ship" button in order view), and there in function i have these line with var dump and etc – user6398 May 8 '14 at 10:04

You problem is that your code is always executed from admin area. So it it always getting store ID of admin store. Which is 0.

To change this you have to fetch the store ID from the order and use as a second parameter of Mage::getStoreConfig(). So in your method it should look like this:

public function salesOrderShipmentSaveBefore($observer)
    $order = $observer->getOrder();
    $title = Mage::getStoreConfig('carriers/tablerate/title', $order->getData('store_id'));
| improve this answer | |
  • ok i just checked with $title = Mage::app()->getStore()->getStor‌​eId(); and it printed NULL – user6398 May 8 '14 at 10:08
  • i suppose you are right then – user6398 May 8 '14 at 10:08
  • ok i got store id from my order like this: $oOrder = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId); $storeID = $oOrder->getData('store_id'); $title = Mage::getStoreConfig('carriers/tablerate/title',Mage::app()->getStore($storeID)); – user6398 May 8 '14 at 10:46
  • I guess the order instance is passed to the observer itself so you don't have to load it again. How are you getting the $orderIncrementId variable? – user487772 May 8 '14 at 11:18
  • public function salesOrderShipmentSaveBefore($observer) { $shipment = $observer->getEvent()->getShipment(); $order = $shipment->getOrder(); $orderIncrementId=$order->getIncrementId(); – user6398 May 8 '14 at 12:12

Which is the result if you use this?

| improve this answer | |
  • it prints "Table Rate" – user6398 May 8 '14 at 9:28

use the below code

$title = Mage::getStoreConfig('carriers/tablerate/title');

also check, is your cache disabled?

| improve this answer | |
  • i already tried this as i mentioned, and yes my cache is disabled, i actually disabled it when i started to do something with magento long long time ago, for just to be sure i flushed it but nothing changes, i get same "Table Rate" printed out on screen – user6398 May 8 '14 at 9:44

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.