VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on October 17, 2018, 17:06:37 PM

Title: Using product remove via own CLI script
Post by: sandomatyas 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:
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?
Title: Re: Using product remove via own CLI script
Post by: Studio 42 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.