Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class C_Insert_Test_model extends CI_Model {
- function __construct() {
- parent::__construct();
- }
- function insert_test_product($post){
- $nb_product = $post["nb_product"];
- if(is_numeric($nb_product)){
- for($i = 0; $i < $nb_product; $i++){
- $this->db->order_by('rand()');
- $this->db->limit(1);
- $query = $this->db->get('VORE_SHOP_category');
- $category = $query->result_array();
- $this->db->order_by('rand()');
- $this->db->limit(1);
- $query = $this->db->get('VORE_SHOP_brands');
- $brand = $query->result_array();
- $insert = [];
- $insert["status"] = 1;
- $insert["sku"] = "99999999";
- $insert["category"] = $category[0]["id"];
- $insert["brand_id"] = $brand[0]["id"];
- $insert["type"] = $post["type"];
- $insert["price_product"] = 10;
- $insert["user_added"] = 999999;
- $insert["date_added"] = date("Y-m-d H:i:s");
- $this->db->insert("VORE_SHOP_product_master", $insert);
- $prod_id = $this->db->insert_id();
- $insert = [];
- $insert["status"] = 1;
- $insert["product_master_id"] = $prod_id;
- $insert["child_id"] = 0;
- $insert["media_id"] = 0;
- $insert["name"] = "test";
- $insert["type"] = "png";
- $this->db->insert("VORE_SHOP_product_images", $insert);
- $insert_title = ["product_id" => $prod_id];
- $insert_slug = ["product_id" => $prod_id];
- $insert_description = ["product_id" => $prod_id];
- foreach($this->all_language as $lang){
- $insert_title[$lang->short_name] = "title product " . $i;
- $insert_slug[$lang->short_name] = "slug_product_" . $i;
- $insert_description[$lang->short_name] = "description product " . $i . " LOREM IPSUM";
- }
- $this->db->insert("VORE_SHOP_product_master_translation_short", $insert_title);
- $title_id = $this->db->insert_id();
- $this->db->insert("VORE_SHOP_product_master_translation_short", $insert_slug);
- $slug_id = $this->db->insert_id();
- $this->db->insert("VORE_SHOP_product_master_translation_long", $insert_description);
- $description_id = $this->db->insert_id();
- $update = ["title_id" => $title_id, "slug_id" => $slug_id, "description_id" => $description_id];
- $this->db->where("id", $prod_id);
- $this->db->update("VORE_SHOP_product_master", $update);
- $update = ["sku" => "prod" . $prod_id . "_test"];
- $this->db->where("id", $prod_id);
- $this->db->update("VORE_SHOP_product_master", $update);
- }
- }
- }
- function insert_test_category($post){
- $nb_category = $post["nb_category"];
- if(is_numeric($nb_category)){
- for($i = 0; $i < $nb_category; $i++){
- $insert = [];
- $insert["status"] = 0;
- $insert["level"] = 0;
- $this->db->insert("VORE_SHOP_category", $insert);
- }
- }
- }
- function insert_test_brand($post){
- $nb_brand = $post["nb_brand"];
- if(is_numeric($nb_brand)){
- for($i = 0; $i < $nb_brand; $i++){
- $insert = [];
- $insert["name"] = "brand" . $i . "_test";
- $insert["status"] = 1;
- $this->db->insert("VORE_SHOP_brands", $insert);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement