I'm developing a script for shop maintenance to delete the oldest 500 disabled products. I want to use the 'deleteProduct' function of the admin Product model, but I can't get the model to load. Below is what I have. What am I doing wrong?
Code: Select all
include '/public/admin/config.php';
include '/public/system/startup.php';
// Registry
$registry = new Registry();
// Config
$config = new Config();
$config->load('default');
$registry->set('config', $config);
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
$registry->set('db', $db);
$query = $db->query("select p.product_id, pd.name, p.date_modified from product p inner join product_description pd on pd.product_id = p.product_id where p.status = 0 and pd.language_id = 1 order by p.date_modified asc limit 2");
foreach ($query->rows as $product)
{
//do the delete here as soon as I get the model function
}
// Model
$loader->model('catalog/product');
$model = $registry->get('model_catalog_product');
$result = $model->getProduct(1); //want to test using the getProduct() function for obvious reasons
var_dump($result);
Who knows the way to load the model and use the functions?PHP Fatal error: Uncaught Error: Call to a member function trigger() on null in /vagrant/public/storage/modification/system/engine/loader.php:240
Stack trace:
#0 /vagrant/public/system/engine/proxy.php(47): Loader->{closure}(Array, Array)
#1 /vagrant/scripts/delete-products.php(37): Proxy->__call('getProduct', Array)
#2 {main}
thrown in /vagrant/public/storage/modification/system/engine/loader.php on line 240