Jump to content

Edit History

ps8modules

ps8modules

ATTENTION !!!
Don't do this.
You will not delete pictures, etc.
I gave you a link to a ready-made solution, I don't understand why you are giving another solution here?

 

<?php
    require_once('./config/config.inc.php');

    $limit = 10;

    $res = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `active` = 0 ORDER BY `id_product` DESC LIMIT '.$limit);

    $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

    $i = 0;

    if ($res) {

        foreach ($res as $row) {
            echo "<p>(".date('Y/m/d H:i:s').") Deleting product with ID <b>".$row['id_product']."</b>...";
            $p = new Product($row['id_product']);
            if(!$p->delete()) {
                echo " <span style='color: red'>Error deleting this product!</span></p>";
            } else {
                echo " <span style='color: green'>DELETED</span></p>";
            }

            $i++;
        }

    }

    if ($i == $limit) {
        echo '<script type="text/javascript">setTimeout(function(){window.top.location="'.$actual_link.'"} , 500);</script>';
    }

 

PHP file (save as Prestashop root folder) and call URL http://your-shop.com/masive-delete-inactive-product.php

 

masive-delete-inactive-product.php

ps8modules

ps8modules

ATTENTION !!!
Don't do this.
You will not delete pictures, etc.
I gave you a link to a ready-made solution, I don't understand why you are giving another solution here?

 

<?php
    require_once('./config/config.inc.php');

    $limit = 10;

    $res = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `active` = 0 ORDER BY `id_product` DESC LIMIT '.$limit);

    $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

    $i = 0;

    if ($res) {

        foreach ($res as $row) {
            echo "<p>(".date('Y/m/d H:i:s').") Deleting product with ID <b>".$row['id_product']."</b>...";
            $p = new Product($row['id_product']);
            if(!$p->delete()) {
                echo " <span style='color: red'>Error deleting this product!</span></p>";
            } else {
                echo " <span style='color: green'>DELETED</span></p>";
            }

            $i++;
        }

    }

    if ($i == $limit) {
        echo '<script type="text/javascript">setTimeout(function(){window.top.location="'.$actual_link.'"} , 500);</script>';
    }

 

PHP file (save as Prestashop root folder) and call URL http://your-shop.com/masive-delete-inactive-product.php

masive-delete-inactive-product.php

 

ps8modules

ps8modules

ATTENTION !!!
Don't do this.
You will not delete pictures, etc.
I gave you a link to a ready-made solution, I don't understand why you are giving another solution here?

 

<?php
    require_once('../config/config.inc.php');

    $limit = 10;

    $res = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `active` = 0 ORDER BY `id_product` DESC LIMIT '.$limit);

    $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

    $i = 0;

    if ($res) {

        foreach ($res as $row) {
            echo "<p>(".date('Y/m/d H:i:s').") Deleting product with ID <b>".$row['id_product']."</b>...";
            $p = new Product($row['id_product']);
            if(!$p->delete()) {
                echo " <span style='color: red'>Error deleting this product!</span></p>";
            } else {
                echo " <span style='color: green'>DELETED</span></p>";
            }

            $i++;
        }

    }

    if ($i == $limit) {
        echo '<script type="text/javascript">setTimeout(function(){window.top.location="'.$actual_link.'"} , 500);</script>';
    }

 

PHP file (save as Prestashop root folder) and call URL http://your-shop.com/masive-delete-inactive-product.php

masive-delete-inactive-product.php

 

ps8modules

ps8modules

ATTENTION !!!
Don't do this.
You will not delete pictures, etc.
I gave you a link to a ready-made solution, I don't understand why you are giving another solution here?

 

<?php
    require_once('../config/config.inc.php');

    $limit = 10;

    $res = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `active` = 0 ORDER BY `id_product` DESC LIMIT '.$limit);

    $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

    $i = 0;

    if ($res) {

        foreach ($res as $row) {
            echo "<p>(".date('Y/m/d H:i:s').") Deleting product with ID <b>".$row['id_product']."</b>...";
            $p = new Product($row['id_product']);
            if(!$p->delete()) {
                echo " <span style='color: red'>Error deleting this product!</span></p>";
            } else {
                echo " <span style='color: green'>DELETED</span></p>";
            }

            $i++;
        }

    }

    if ($i == $limit) {
        echo '<script type="text/javascript">setTimeout(function(){window.top.location="'.$actual_link.'"} , 500);</script>';
    }

 

PHP file (save as Prestashop root folder) and call URL http://your-shop.com/masice-delete-inactive-product.php

masive-delete-inactive-product.php

 

×
×
  • Create New...