magento表"sales_flat_order"字段"protect_code";解释 [英] magento table "sales_flat_order" field "protect_code" explanation

查看:124
本文介绍了magento表"sales_flat_order"字段"protect_code";解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在研究magento数据库和表格. Magento似乎在表sales_flat_order字段protect_code中编写了代码,以定义是否已完成发票或装运.看起来像

We are working on magento database and tables. Magento seems to write a code in table sales_flat_order field protect_code to define if there is a invoice or a shipment done already. It would look something like

01b335
a0a243

但是没有key可以理解此保护代码的含义.这些代码的含义及其生成方式是否得到解释?

But there is no key to understand what this protection code means. Is there an explanation of the meaning of these codes and how they are generated?

推荐答案

它在哪里生成?

如果您在2052行附近的app/code/core/Mage/Sales/Model/Order.php中查看,则会发现以下内容:

Where is it generated?

If you look in app/code/core/Mage/Sales/Model/Order.php on around line 2052, you will find the following:

$this->setData('protect_code', substr(md5(uniqid(mt_rand(), true) . ':' . microtime(true)), 5, 6));

这是为订单生成protect_code的地方(使用md5,uniqid和随机整数的组合.

This is where protect_code is generated for the order (using a combination of md5, uniqid, and random integer.

如果您查看app/code/core/Mage/Sales/Helper/Guest.php并找到loadValidOrder函数.您会在某些区域看到protect_code,以确保所加载的订单对于来宾的cookie值而言是正确的.

If you look in app/code/core/Mage/Sales/Helper/Guest.php and find the loadValidOrder function. You will see protect_code used in some areas to ensure the order being loaded is the correct one for the guest's cookie value.

它还用于其他领域,例如跟踪信息比较.您可以看到在Shipment模型中调用了getProtectCode()方法的多个实例,以将订单与跟踪信息进行比较.使用它的函数的一个示例是:

It's also used in other areas, such as tracking information comparisons. You can see several instances of the getProtectCode() method being called in the Shipment models to compare the order to the tracking information. An example of a function that uses it is:

public function getTrackingInfoByTrackId()
{
    $track = Mage::getModel('sales/order_shipment_track')->load($this->getTrackId());
    if ($track->getId() && $this->getProtectCode() == $track->getProtectCode()) {
        $this->_trackingInfo = array(array($track->getNumberDetail()));
    }
    return $this->_trackingInfo;
}

$this->getProtectCode() == $track->getProtectCode()所示,跟踪protect_code必须与货运protect_code相匹配.

As you can see with $this->getProtectCode() == $track->getProtectCode(), the tracking protect_code must match the Shipment protect_code.

这篇关于magento表"sales_flat_order"字段"protect_code";解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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