如何在 Magento 1.5 中自定义订单、发票等的起始编号?
4 回答
来自magento的论坛:
- 通过 LindyKyaw(Magento 团队成员),更改起始编号(通过 sql 查询):
数据库中有一个存储订单增量ID的表。 它被称为“eav_entity_store”表。 您可以通过查看来检查哪个实体类型 id 属于哪个实体 eav_entity_type 表。 您可以运行以下查询来更新订单的最后一个增量 ID。update eav_entity_store inner join eav_entity_type on eav_entity_type.entity_type_id = eav_entity_store.entity_type_id set eav_entity_store.increment_last_id=3001 where eav_entity_type.entity_type_code='order';
- 通过 FOOMAN(活跃贡献者),更改开始编号(通过数据库管理工具)并删除开头的“0”:
希望有帮助使用 phpmyadmin 之类的工具查看您的数据库。在表中 eav_entity_type 您将找到列出的所有实体类型。感兴趣的一个 更改订单号开始的位置是订单销售/订单。记住 entity_type_id(在我的安装中是 11)。删除前导零 (填充)将 increment_pad_length 设置为 1。接下来转到表 eav_entity_store。查找 entity_type_id。现在轮到你 可以改变 increment_prefix 和 increment_last_id 的值。如果你想 让您的下一个 orderId 为 15000 将 increment_last_id 设置为 14999 和 增量前缀为 0。
此外,您需要制作此文件的副本 /app/code/core/Mage/Eav/Model/Entity/Increment/Abstract.php 到 /app/code/local/Mage/Eav/Model/Entity/Increment/Abstract.php
public function getPadLength() { $padLength = $this->getData('pad_length'); if (empty($padLength)) { $padLength = 0; } return $padLength; } ... public function format($id) { $result= str_pad((string)$id, $this->getPadLength(), $this->getPadChar(), STR_PAD_LEFT); return $result; }
Magento 订购不
,这很简单....
- 去phpmyadmin
- 选择您的数据库,然后选择表“eav_entity_store”
- 在此表中,更改
increment_last_id
(例如,我在表中设置了 3456767) - 之后我创建一个新订单。现在我的订单从号码 346768 开始
实际上,对于较新的版本(可能也在 1.5 中),有一种更简单的方法可以更改它。在 PHPMyAdmin 或您的 mysql 客户端中,转到eav_entity_type
表。在entity_type_code
列中找到表(可能是order
),然后将 设置为increment_pad_length
您想要的任何内容,以及increment_pad_char
.
然后你不必重写核心代码——双赢。
最大
实际上有一个很好的扩展来完成这个任务。
它允许您以多种不同的方式自定义订单 ID:例如,您可以使用以下组合:
- 像年、月、日、小时、秒这样的数字,
- 使用自定义计数器(您可以决定起始编号)
- 以上所有方法的组合
- 在订单 ID 的任何位置添加一些自定义字符串
这是分机。关于 Magento 连接: http: //www.magentocommerce.com/magento-connect/custom-order-id-8210.html
我亲自尝试过,它非常好(适用于我所有的付款方式,我完全没有问题)