Рейтинг 4.0 из 5. Голосов: 1

mysql zaprosi

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

Перед любым изменением в базе данных, неплохо бы сделать бекап БД!
Для этого подойдет например скрипт Adminer или Phpmyadmin.

Для удаленияя завписей в БД вашего магазина, достаточно прописать запрос к базе данных:

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

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_seo_url WHERE query LIKE 'category_id=%'

Удалить только Seo URL от категорий

DELETE FROM oc_seo_url WHERE query LIKE 'category_id=%'

Очистить все товары в Opencart 3:

SET foreign_key_checks = 0;
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_seo_url WHERE query LIKE 'product_id=%'

Удалить только Seo URL от товаров

DELETE FROM oc_seo_url WHERE query LIKE 'product_id=%'

Как очистить все атрибуты в 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;

Удаление всех производителей

TRUNCATE TABLE oc_manufacturer

Удаление всех заказов

TRUNCATE TABLE oc_order;
TRUNCATE TABLE oc_order_history;
TRUNCATE TABLE oc_order_option;
TRUNCATE TABLE oc_order_product;
TRUNCATE TABLE oc_order_recurring;
TRUNCATE TABLE oc_order_recurring_transaction;
TRUNCATE TABLE oc_order_total;
TRUNCATE TABLE oc_order_voucher;

Удаление всех покупателей

TRUNCATE oc_customer;
TRUNCATE oc_customer_activity;
TRUNCATE oc_customer_history;
TRUNCATE oc_customer_login;
TRUNCATE oc_customer_ip;
TRUNCATE oc_customer_online;
TRUNCATE oc_customer_reward;
TRUNCATE oc_customer_transaction;
TRUNCATE oc_customer_search;
TRUNCATE oc_customer_wishlist;
TRUNCATE oc_custom_field;
TRUNCATE oc_custom_field_customer_group;
TRUNCATE oc_custom_field_description;
TRUNCATE oc_custom_field_value;
TRUNCATE oc_custom_field_value_description;

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

Просмотров: 1031 Печать Назад