Author Topic: Using product remove via own CLI script  (Read 522 times)

sandomatyas

  • Jr. Member
  • **
  • Posts: 302
Using product remove via own CLI script
« on: October 17, 2018, 17:06:37 pm »
I need to create a CLI script which removes some products from VirtueMart in certain circumstances. It needs to be executed in every hour, check some dependencies and remove the products which they don't need anymore.
I can use VirtueMartModelProduct class remove function for that but there is an access check there:
Code: [Select]
if(!vmAccess::manager('product.delete')){
vmWarn('Insufficient permissions to delete product');
return false;
}
How should I set a proper access for that in an external script?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4381
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Using product remove via own CLI script
« Reply #1 on: October 17, 2018, 22:59:39 pm »
A simple way is to use a plugin(ajax or system) and call this script.
You have then simply to copy the model delete function and remove the access check and protect it with a strong password for eg.