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 invoi
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));
This is where protect_code
is generated for the order (using a combination of md5, uniqid, and random integer.
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.
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;
}
As you can see with $this->getProtectCode() == $track->getProtectCode()
, the tracking protect_code
must match the Shipment protect_code
.