Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. public function deactivateProductsWithoutImage() {
  2. global $db, $logger;
  3. $db->query('SET autocommit = 0');
  4. $deactivedProductImages= "";
  5. foreach ($db->query("select * from "._DB_PREFIX_."product p where id_product not in( select id_product from "._DB_PREFIX_."image )") as $product) {
  6. $db->query("UPDATE "._DB_PREFIX_."product SET active = 0 WHERE id_product={$product['id_product']}; ");
  7. $db->query("UPDATE "._DB_PREFIX_."product_shop SET active = 0 WHERE id_product={$product['id_product']};");
  8. $deactivedProductImages[] = $product['reference'];
  9. }
  10. $db->query('commit');
  11. $logger->LogCron(" - Deactivated Items Without Image = " .count($deactivedProductImages) ." items => " . implode(",", $deactivedProductImages)." ");
  12. }
  13.  
  14. public function remove_images($id_image) {
  15. global $logger, $db;
  16. if (!isset($this->image_types)) {
  17. $this->image_types = array();
  18. foreach ($db->query("SELECT * FROM `"._DB_PREFIX_."image_type` WHERE `products` = 1") as $image_type) {
  19. $this->image_types[] = array(
  20. 'width' => $image_type['width'],
  21. 'height' => $image_type['height'],
  22. 'name' => $image_type['name']
  23. );
  24. }
  25. }
  26. if(count($this->image_types))
  27. foreach($this->image_types as $image_type) {
  28. $f = IMAGE_ABS_PATH . implode('/', str_split($id_image)) . '/' . $id_image . "-". $image_type['name'].".jpg";
  29. @unlink($f);
  30. $logger->LogCron(" REMOVED Image $f");
  31. }
  32. return true;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement