News:

Support the VirtueMart project and become a member

Main Menu

Using product remove via own CLI script

Started by sandomatyas, October 17, 2018, 17:06:37 PM

Previous topic - Next topic

sandomatyas

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:
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

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.