Opencart 2: Add the current registered administrator ID to the oc_product table to insert the product

I would like to keep track of which dashboard user ("admin") added the new product to the database.

The solution I was thinking about is simply adding another insertunder admin > model > catalog > product.tplin function addProduct()that adds the user id to the user column added before oc_product.

$userID = // currently logged in

public function addProduct($data) {

$this->event->trigger('pre.admin.product.add', $data);

$this->db->query("INSERT INTO " . DB_PREFIX . "product SET addedby = $userID, .......");

.......

}

The only problem that I am facing right now is how to call / get the current registered administrator ID inside this file (model / catalog / product.tpl).

This is how I think about it, if this idea is completely wrong, write some of the best solutions.

+4
2
  • ( , )
  • $this->user->getId()
  • $userID = $this->user->getId() addProduct,
  • product added_by,
+3

, , . user_id product_id product_id . , product_id.

+5

All Articles