I would like to monitor which dashboard user ("admin") added new product to the database.
The solution i was thinking about is simply adding another insert
under admin > model > catalog > product.tpl
under function addProduct()
, which adds the user id to the custom column added before under 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 I have now is how to call / get the currently logged admin id inside this file (model/catalog/product.tpl).
This is just how i think about it, if this idea is completely wrong, please do write some better solutions.
It would be better if you create another table to store this information since it will save you from altering the core table. In new table you store the user_id and product_id and set product_id as primary key. Now you will be able to fetch this data as you require by joining these two tables ON basis of product_id match.
$this->user->getId()
$userID = $this->user->getId()
inside the addProduct
function, not inside the class declarationadded_by
in product
table, you will have to alter the table structure and add itIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With