在sales/Ordercontroller magento后端中获取sales_quote模型 [英] get sales_quote model in sales/Ordercontroller magento backend

查看:92
本文介绍了在sales/Ordercontroller magento后端中获取sales_quote模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在订单控制器Magento后端中获得sales_quote模型?我需要在ordercontroller中获取报价详细信息,所以我正在使用以下代码.

How can I get sales_quote model in ordercontroller Magento backend? I need to get the quote details in the ordercontroller, so I'm using the following code.

$quote= Mage::getModel('sales/quote')->load($quoteid);

以上查询返回空数据.在下面

Above query returns empty data. which is below

  Mage_Sales_Model_Quote Object
(
    [_eventPrefix:protected] => sales_quote
    [_eventObject:protected] => quote
    [_customer:protected] => 
    [_addresses:protected] => 
    [_items:protected] => 
    [_payments:protected] => 
    [_errorInfoGroups:protected] => Array
        (
        )

    [_preventSaving:protected] => 
    [_resourceName:protected] => sales/quote
    [_resource:protected] => 
    [_resourceCollectionName:protected] => sales/quote_collection
    [_cacheTag:protected] => 
    [_dataSaveAllowed:protected] => 1
    [_isObjectNew:protected] => 
    [_data:protected] => Array
        (
        )

    [_hasDataChanges:protected] => 
    [_origData:protected] => 
    [_idFieldName:protected] => 
    [_isDeleted:protected] => 
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)

有什么方法可以报价?

推荐答案

我遇到了同样的问题.在看了一段时间的代码后,我遇到了这个功能:

I was having the same problem. After looking through the code for a while I came across this function:

Mage_Sales_Model_Quote::loadByIdWithoutStore()

我猜想常规的Mage_Sales_Model_Quote::load()函数会自动附加当前的storeview来加载报价对象.在这种情况下,storeview是admin,这意味着找不到引用ID的结果,并且返回的对象为空.

I guess the regular Mage_Sales_Model_Quote::load() function automatically attaches the current storeview to load the quote object. In this case the storeview is admin, which means no results will be found for the quote id and the returned object is empty.

根据您的情况,这应该可以正常工作:

In your case, this should work as expected:

$quote= Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteid); 

这篇关于在sales/Ordercontroller magento后端中获取sales_quote模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆