Jump to content
Sign in to follow this  
Grandifer

Как массово удалить товары одной категории

Recommended Posts

Как массово удалить товары одной категории? Предполагаю, что логично просто добавить фильтр по категориям на странице товаров в админке, потом отмечать все товары страницы и удалить. Но проблема в том, что я плохо разбираюсь в коде и даже не понимаю, какой файл нужно для этого редактировать. Может кто подскажет куда копать? Или готовое решение даст? Был бы весьма благодарен.

Share this post


Link to post
Share on other sites

Зайти в раздел товары, отфильтровать по категории и удалять.

Товаров сколько?

Share this post


Link to post
Share on other sites

Зайти в раздел товары, отфильтровать по категории и удалять.

Товаров сколько?

Так ведь в том и дело, что я не вижу фильтра по категориям в товарах (oc 1.5.51)

Всего ~3.5k, из них около половины нужно удалить. Выборочно.

Share this post


Link to post
Share on other sites

Недавно тоже искал вариант удаления товаров из категории. Написал простой php скрипт. Кому-то пригодится.

Ocstore 2.1

<?php
$server = "localhost";
$db = "test";
$username = "vasya";
$password = "pupkin";

//Connect to Mysql
$link = mysqli_connect($server, $username, $password, $db);
if (mysqli_connect_errno()) {
    printf("ERROR $server: %s\n", mysqli_connect_error());
    exit();
}
mysqli_set_charset($link, "utf8");

$q1 = mysqli_query($link,"SELECT product_id from oc_product_to_category WHERE category_id='63'");

while ($f1 = mysqli_fetch_array($q1)){
    $product_id = $f1[0];
    mysqli_query($link,"DELETE FROM oc_product WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_attribute WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_description WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_discount WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_filter WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_image WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_option WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_option_value WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_related WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_related WHERE related_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_reward WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_special WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_to_category WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_to_download WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_to_layout WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_to_store WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_product_recurring WHERE product_id = " . (int)$product_id);
    mysqli_query($link,"DELETE FROM oc_review WHERE product_id = '" . (int)$product_id . "'");
    mysqli_query($link,"DELETE FROM oc_url_alias WHERE query = 'product_id=" . (int)$product_id . "'");
}

mysqli_close($link);

?>

 

Edited by tambu34

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.