OpenCart automatically add new products. Products manipulation
mysql, opencart, php
Solution
If you have them in an array then it is a piece of cake. There is a method in opencart in admin/model/catalog which you can use, addProduct(). Read the indexes of the $data array and try to bring your array in that form. Eg in this method you can see $data['model'], $data['image'], etc. Assuming you have done so you can create a new controller file, say in admin/controller/module/script.php with some code like the following.
<?php
class ControllerCatalogProduct extends Controller {
public function index() {
$products = array(...); //your products here. Eg $products[0] has all the data for the first product
$this->load->model('catalog/product');
foreach ($products as $data) {
$this->model_catalog_product->addProduct($data);
}
}
}
?>
Simple as that. Then you call this through `http://yoursite/admin/index.php?route=module/script`
Problem
I am new to `opencart`, and I have to write code which will automatically add/delete/edit products on that opencart website, so my question is the following : How to add new products to the database automatically with php? (Maybe there are some methods in opencart, so I can use them, or I have to write the code from scratch?) P.S: an example will be great (suppose we have the product information in an array) P.P.S: not all products will be added automatically.