Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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()); 
            var_dump($title);
            die();

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.

share|improve this question
1  
Where are you trying to execute this code? –  Tim Bezhashvyly May 8 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 at 10:04

3 Answers 3

up vote 3 down vote accepted

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'));
    ...
}
share|improve this answer
    
ok i just checked with $title = Mage::app()->getStore()->getStor‌​eId(); and it printed NULL –  user6398 May 8 at 10:08
    
i suppose you are right then –  user6398 May 8 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 at 10:46
    
thanks for help, i got just what i wanted :) –  user6398 May 8 at 10:47
    
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? –  Tim Bezhashvyly May 8 at 11:18

Which is the result if you use this?

Mage::app()->getStore()->getConfig('carriers/tablerate/title');
share|improve this answer
    
it prints "Table Rate" –  user6398 May 8 at 9:28

use the below code

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

also check, is your cache disabled?

share|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 at 9:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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