Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function deactivateProductsWithoutImage() {
- global $db, $logger;
- $db->query('SET autocommit = 0');
- $deactivedProductImages= "";
- foreach ($db->query("select * from "._DB_PREFIX_."product p where id_product not in( select id_product from "._DB_PREFIX_."image )") as $product) {
- $db->query("UPDATE "._DB_PREFIX_."product SET active = 0 WHERE id_product={$product['id_product']}; ");
- $db->query("UPDATE "._DB_PREFIX_."product_shop SET active = 0 WHERE id_product={$product['id_product']};");
- $deactivedProductImages[] = $product['reference'];
- }
- $db->query('commit');
- $logger->LogCron(" - Deactivated Items Without Image = " .count($deactivedProductImages) ." items => " . implode(",", $deactivedProductImages)." ");
- }
- public function remove_images($id_image) {
- global $logger, $db;
- if (!isset($this->image_types)) {
- $this->image_types = array();
- foreach ($db->query("SELECT * FROM `"._DB_PREFIX_."image_type` WHERE `products` = 1") as $image_type) {
- $this->image_types[] = array(
- 'width' => $image_type['width'],
- 'height' => $image_type['height'],
- 'name' => $image_type['name']
- );
- }
- }
- if(count($this->image_types))
- foreach($this->image_types as $image_type) {
- $f = IMAGE_ABS_PATH . implode('/', str_split($id_image)) . '/' . $id_image . "-". $image_type['name'].".jpg";
- @unlink($f);
- $logger->LogCron(" REMOVED Image $f");
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement