Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Add post

Add question

You must login to ask a question.

Login

Register Now

Цель сайта совместная помощь друг другу, если вы желаете скачивать ресурсы и ничего при этом не делать, вам нужно оплатить Подписку Другой вариант активно помогать другим участникам

Очистка Сущностей Товара (Продукты, Категории, Опции) Методы запросов в БД

Очистка Сущностей Товара (Продукты, Категории, Опции) Методы запросов в БД

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

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

public function truncateAllProductData()
{
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "coupon_product");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_attribute");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_description");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_discount");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_filter");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_image");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_option");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_option_value");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_related");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_reward");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_special");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_to_category");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_to_download");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_to_layout");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_to_store");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "product_recurring");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "return");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "review");
}

Удаление всех категорий:

public function truncateAllCategoryData()
{
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "category");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "category_description");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "category_to_store");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "category_filter");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "category_to_layout");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "category_path");
}

Удаление всех опций:

public function truncateAllOptionData()
{
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "option");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "option_description");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "option_value");
$this->db->query("TRUNCATE TABLE " . DB_PREFIX . "option_value_description");
}

 

About Tapac

Leave a reply