如何在 product_add_after 事件中获得 product_id?
How to get the product_id on the product_add_after event?
我有一个在 OpenCart 3.0.3.1 中的 after_product_add 事件上触发的模块。在代码中,我想向产品添加信息,但为此我需要 product_id,它不包含在我从事件中获得的数据数组中。
有没有人知道除了修改OpenCart源代码之外的解决方案?
背景资料:
该模块将与另一个系统同步产品,在创建时我想在数据库中存储一个 guid。为此,我需要 product_id.
我从事件触发器中得到的数组是:
大批
(
[0] => 数组
(
[product_description] => 数组
(
[1] => 数组
(
[名称] => test25
[说明] =>
[meta_title] => 测试 25
[meta_description] =>
[meta_keyword] =>
[标签] =>
)
)
[model] => test25
[sku] =>
[upc] =>
[ean] =>
[jan] =>
[isbn] =>
[mpn] =>
[location] =>
[price] =>
[tax_class_id] => 0
[quantity] => 1
[minimum] => 1
[subtract] => 1
[stock_status_id] => 6
[shipping] => 1
[date_available] => 2019-06-04
[length] =>
[width] =>
[height] =>
[length_class_id] => 1
[weight] =>
[weight_class_id] => 1
[status] => 1
[sort_order] => 1
[manufacturer] =>
[manufacturer_id] => 0
[category] =>
[filter] =>
[product_store] => Array
(
[0] => 0
)
[download] =>
[related] =>
[option] =>
[image] =>
[points] =>
[product_reward] => Array
(
[1] => Array
(
[points] =>
)
)
[product_seo_url] => Array
(
[0] => Array
(
[1] =>
)
)
[product_layout] => Array
(
[0] =>
)
)
)
我搜索了论坛和开发者文档。我找到的唯一参考资料告诉我,没有比我已经拥有的更多的信息了。我试图从请求中获取产品 ID
public function createproduct($route, $args) {
if ($this->config->get('module_umrlzconn_status')) {
if ($this->config->get('module_umrlzconn_productsync')) {
$this->load->model('extension/module/umrlzconn');
file_put_contents(DIR_STORAGE .'UMRLZ/prodcreate.log', print_r($args,true));
$productguid = $this->NewGuid();
$this->model_extension_module_umrlzconn->setProductGuid($this->request->get['product_id'], $productguid);
}
}
}
我想为刚刚创建的产品获取 product_id,以便我可以使用它向其中添加信息。
任何搜索答案的人,感谢 OpenCart 论坛上的 DigitCart,product_id 作为第三个变量与 event-action 一起发送。这样就可以得到product id如下:
public function createproduct($route, $args, $product_id) {
// Do your thing
}
我有一个在 OpenCart 3.0.3.1 中的 after_product_add 事件上触发的模块。在代码中,我想向产品添加信息,但为此我需要 product_id,它不包含在我从事件中获得的数据数组中。
有没有人知道除了修改OpenCart源代码之外的解决方案?
背景资料: 该模块将与另一个系统同步产品,在创建时我想在数据库中存储一个 guid。为此,我需要 product_id.
我从事件触发器中得到的数组是: 大批 ( [0] => 数组 ( [product_description] => 数组 ( [1] => 数组 ( [名称] => test25 [说明] => [meta_title] => 测试 25 [meta_description] => [meta_keyword] => [标签] => )
)
[model] => test25
[sku] =>
[upc] =>
[ean] =>
[jan] =>
[isbn] =>
[mpn] =>
[location] =>
[price] =>
[tax_class_id] => 0
[quantity] => 1
[minimum] => 1
[subtract] => 1
[stock_status_id] => 6
[shipping] => 1
[date_available] => 2019-06-04
[length] =>
[width] =>
[height] =>
[length_class_id] => 1
[weight] =>
[weight_class_id] => 1
[status] => 1
[sort_order] => 1
[manufacturer] =>
[manufacturer_id] => 0
[category] =>
[filter] =>
[product_store] => Array
(
[0] => 0
)
[download] =>
[related] =>
[option] =>
[image] =>
[points] =>
[product_reward] => Array
(
[1] => Array
(
[points] =>
)
)
[product_seo_url] => Array
(
[0] => Array
(
[1] =>
)
)
[product_layout] => Array
(
[0] =>
)
)
)
我搜索了论坛和开发者文档。我找到的唯一参考资料告诉我,没有比我已经拥有的更多的信息了。我试图从请求中获取产品 ID
public function createproduct($route, $args) {
if ($this->config->get('module_umrlzconn_status')) {
if ($this->config->get('module_umrlzconn_productsync')) {
$this->load->model('extension/module/umrlzconn');
file_put_contents(DIR_STORAGE .'UMRLZ/prodcreate.log', print_r($args,true));
$productguid = $this->NewGuid();
$this->model_extension_module_umrlzconn->setProductGuid($this->request->get['product_id'], $productguid);
}
}
}
我想为刚刚创建的产品获取 product_id,以便我可以使用它向其中添加信息。
任何搜索答案的人,感谢 OpenCart 论坛上的 DigitCart,product_id 作为第三个变量与 event-action 一起发送。这样就可以得到product id如下:
public function createproduct($route, $args, $product_id) {
// Do your thing
}