我如何获得当前商店的运输方式:Magento

Dee*_*tia 3 magento magento-1.9

我正在创建功能,以便为选定的商店启用送货方式.

目前我使用下面的代码来获取运输详情:

$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
$shipMethods = array();

foreach ($methods as $shippigCode=>$shippingModel) 
{

    $shippingTitle = Mage::getStoreConfig('carriers/'.$shippigCode.'/title');
    $shippingPrice = Mage::getStoreConfig('carriers/'.$shippigCode.'/price');
    $shippingLabel = Mage::getStoreConfig('carriers/'.$shippigCode.'/label');
    $shipMethods[]=array('Shipping Type' => $shippigCode, 'title'=> $shippingTitle, 'price'=> $shippingPrice);


}
print_r($shipMethods);
Run Code Online (Sandbox Code Playgroud)

我只获得默认商店的配置详细信息.

我的问题是:我如何获得所选商店的送货方式?

小智 6

默认情况下,getActiveCarriers中的值为null

getActiveCarriers($store = null)

因此,您可以将商店作为参数传递.您可以使用当前商店

Mage::app()->getStore()->getStoreId()
Run Code Online (Sandbox Code Playgroud)

所以你将使用的功能是

Mage::getSingleton('shipping/config')->getActiveCarriers(Mage::app()->getStore()->getStoreId())
Run Code Online (Sandbox Code Playgroud)