Очистка всех данных о товарах в Opencart 2x через запрос в базу данных

Важно!!! Перед любым изменением в базе данных, необходимо делать бекап базы данных!!!

При создании нового магазина, часто требуется очистить демо товары или ошибочно загруженные товары (атрибуты, категории).

Сделать это все просто, достаточно прописать запрос к базе данных:

Очистка всех категорий, товаров, атрибутов, опций и производителей в Opencart:

TRUNCATE TABLE `oc_category`;
TRUNCATE TABLE `oc_category_description`;
TRUNCATE TABLE `oc_category_filter`;
TRUNCATE TABLE `oc_category_path`;
TRUNCATE TABLE `oc_category_to_layout`;
TRUNCATE TABLE `oc_category_to_store`;
DELETE FROM oc_url_alias WHERE query LIKE 'category_id=%';
TRUNCATE TABLE oc_product;
TRUNCATE TABLE oc_product_attribute;
TRUNCATE TABLE oc_product_description;
TRUNCATE TABLE oc_product_discount;
TRUNCATE TABLE oc_product_image;
TRUNCATE TABLE oc_product_option;
TRUNCATE TABLE oc_product_option_value;
TRUNCATE TABLE oc_product_related;
TRUNCATE TABLE oc_product_related;
TRUNCATE TABLE oc_product_reward;
TRUNCATE TABLE oc_product_special;
TRUNCATE TABLE oc_product_to_category;
TRUNCATE TABLE oc_product_to_download;
TRUNCATE TABLE oc_product_to_layout;
TRUNCATE TABLE oc_product_to_store;
TRUNCATE TABLE oc_review;
DELETE FROM oc_url_alias WHERE query LIKE 'product_id=%';
TRUNCATE TABLE oc_attribute;
TRUNCATE TABLE oc_attribute_description;
TRUNCATE TABLE oc_attribute_group;
TRUNCATE TABLE oc_attribute_group_description;
TRUNCATE TABLE oc_product_attribute;
TRUNCATE TABLE oc_option;
TRUNCATE TABLE oc_option_description;
TRUNCATE TABLE oc_option_value;
TRUNCATE TABLE oc_option_value_description;
TRUNCATE TABLE oc_product_option;
DELETE FROM oc_url_alias WHERE query LIKE 'manufacturer_id=%';
TRUNCATE TABLE oc_manufacturer;
TRUNCATE TABLE oc_manufacturer_description;
TRUNCATE TABLE oc_manufacturer_to_store;


Как очистить все категории в Opencart :

TRUNCATE TABLE `oc_category`;
TRUNCATE TABLE `oc_category_description`;
TRUNCATE TABLE `oc_category_filter`;
TRUNCATE TABLE `oc_category_path`;
TRUNCATE TABLE `oc_category_to_layout`;
TRUNCATE TABLE `oc_category_to_store`;
DELETE FROM oc_url_alias WHERE query LIKE 'category_id=%';

Как очистить все товары в Opencart:

TRUNCATE TABLE oc_product;
TRUNCATE TABLE oc_product_attribute;
TRUNCATE TABLE oc_product_description;
TRUNCATE TABLE oc_product_discount;
TRUNCATE TABLE oc_product_image;
TRUNCATE TABLE oc_product_option;
TRUNCATE TABLE oc_product_option_value;
TRUNCATE TABLE oc_product_related;
TRUNCATE TABLE oc_product_related;
TRUNCATE TABLE oc_product_reward;
TRUNCATE TABLE oc_product_special;
TRUNCATE TABLE oc_product_to_category;
TRUNCATE TABLE oc_product_to_download;
TRUNCATE TABLE oc_product_to_layout;
TRUNCATE TABLE oc_product_to_store;
TRUNCATE TABLE oc_review;
DELETE FROM oc_url_alias WHERE query LIKE 'product_id=%';

если вы увидите подобную надпись (ошибку):

#1146 - Table 'p254341_smarket.oc_product_tag' doesn't exist

то удалите ее из запроса.

Как очистить все атрибуты в Opencart:

TRUNCATE TABLE oc_attribute;
TRUNCATE TABLE oc_attribute_description;
TRUNCATE TABLE oc_attribute_group;
TRUNCATE TABLE oc_attribute_group_description;
TRUNCATE TABLE oc_product_attribute;

Как очистить все опции в Opencart:

TRUNCATE TABLE oc_option;
TRUNCATE TABLE oc_option_description;
TRUNCATE TABLE oc_option_value;
TRUNCATE TABLE oc_option_value_description;
TRUNCATE TABLE oc_product_option;

Комментарии 0