Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('BASEPATH'))
  4. exit('No direct script access allowed');
  5.  
  6. class C_Insert_Test_model extends CI_Model {
  7.  
  8. function __construct() {
  9. parent::__construct();
  10. }
  11.  
  12. function insert_test_product($post){
  13. $nb_product = $post["nb_product"];
  14. if(is_numeric($nb_product)){
  15. for($i = 0; $i < $nb_product; $i++){
  16. $this->db->order_by('rand()');
  17. $this->db->limit(1);
  18. $query = $this->db->get('VORE_SHOP_category');
  19. $category = $query->result_array();
  20. $this->db->order_by('rand()');
  21. $this->db->limit(1);
  22. $query = $this->db->get('VORE_SHOP_brands');
  23. $brand = $query->result_array();
  24. $insert = [];
  25. $insert["status"] = 1;
  26. $insert["sku"] = "99999999";
  27. $insert["category"] = $category[0]["id"];
  28. $insert["brand_id"] = $brand[0]["id"];
  29. $insert["type"] = $post["type"];
  30. $insert["price_product"] = 10;
  31. $insert["user_added"] = 999999;
  32. $insert["date_added"] = date("Y-m-d H:i:s");
  33. $this->db->insert("VORE_SHOP_product_master", $insert);
  34. $prod_id = $this->db->insert_id();
  35. $insert = [];
  36. $insert["status"] = 1;
  37. $insert["product_master_id"] = $prod_id;
  38. $insert["child_id"] = 0;
  39. $insert["media_id"] = 0;
  40. $insert["name"] = "test";
  41. $insert["type"] = "png";
  42. $this->db->insert("VORE_SHOP_product_images", $insert);
  43. $insert_title = ["product_id" => $prod_id];
  44. $insert_slug = ["product_id" => $prod_id];
  45. $insert_description = ["product_id" => $prod_id];
  46. foreach($this->all_language as $lang){
  47. $insert_title[$lang->short_name] = "title product " . $i;
  48. $insert_slug[$lang->short_name] = "slug_product_" . $i;
  49. $insert_description[$lang->short_name] = "description product " . $i . " LOREM IPSUM";
  50. }
  51. $this->db->insert("VORE_SHOP_product_master_translation_short", $insert_title);
  52. $title_id = $this->db->insert_id();
  53. $this->db->insert("VORE_SHOP_product_master_translation_short", $insert_slug);
  54. $slug_id = $this->db->insert_id();
  55. $this->db->insert("VORE_SHOP_product_master_translation_long", $insert_description);
  56. $description_id = $this->db->insert_id();
  57. $update = ["title_id" => $title_id, "slug_id" => $slug_id, "description_id" => $description_id];
  58. $this->db->where("id", $prod_id);
  59. $this->db->update("VORE_SHOP_product_master", $update);
  60.  
  61. $update = ["sku" => "prod" . $prod_id . "_test"];
  62. $this->db->where("id", $prod_id);
  63. $this->db->update("VORE_SHOP_product_master", $update);
  64. }
  65. }
  66. }
  67.  
  68.  
  69. function insert_test_category($post){
  70. $nb_category = $post["nb_category"];
  71. if(is_numeric($nb_category)){
  72. for($i = 0; $i < $nb_category; $i++){
  73. $insert = [];
  74. $insert["status"] = 0;
  75. $insert["level"] = 0;
  76. $this->db->insert("VORE_SHOP_category", $insert);
  77.  
  78.  
  79. }
  80. }
  81. }
  82.  
  83. function insert_test_brand($post){
  84. $nb_brand = $post["nb_brand"];
  85. if(is_numeric($nb_brand)){
  86. for($i = 0; $i < $nb_brand; $i++){
  87. $insert = [];
  88. $insert["name"] = "brand" . $i . "_test";
  89. $insert["status"] = 1;
  90. $this->db->insert("VORE_SHOP_brands", $insert);
  91. }
  92. }
  93. }
  94.  
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement