Разные цены для разных доменов

This commit is contained in:
Konstantin
2026-05-30 13:29:07 +03:00
parent 4f25e4968e
commit 9b60eea881
7 changed files with 208 additions and 310 deletions
+15 -2
View File
@@ -22,6 +22,9 @@ class ModelCatalogProduct extends Model {
}
}
$this->load->model('catalog/product_price');
$this->model_catalog_product_price->addProductPrices($product_id, $data);
if (isset($data['product_attribute'])) {
foreach ($data['product_attribute'] as $product_attribute) {
if ($product_attribute['attribute_id']) {
@@ -180,6 +183,9 @@ class ModelCatalogProduct extends Model {
}
}
$this->load->model('catalog/product_price');
$this->model_catalog_product_price->editProductPrices($product_id, $data);
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "'");
if (!empty($data['product_attribute'])) {
@@ -379,8 +385,9 @@ class ModelCatalogProduct extends Model {
$data['product_category'] = $this->getProductCategories($product_id);
$data['product_download'] = $this->getProductDownloads($product_id);
$data['product_layout'] = $this->getProductLayouts($product_id);
$data['product_store'] = $this->getProductStores($product_id);
$data['product_recurrings'] = $this->getRecurrings($product_id);
$data['product_store'] = $this->getProductStores($product_id);
$data['product_prices'] = $this->getProductPrices($product_id);
$data['product_recurrings'] = $this->getRecurrings($product_id);
$this->addProduct($data);
}
@@ -404,6 +411,7 @@ class ModelCatalogProduct extends Model {
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_prices WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_recurring WHERE product_id = " . (int)$product_id);
$this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE product_id = '" . (int)$product_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'product_id=" . (int)$product_id . "'");
@@ -722,6 +730,11 @@ class ModelCatalogProduct extends Model {
return $product_store_data;
}
public function getProductPrices($product_id) {
$this->load->model('catalog/product_price');
return $this->model_catalog_product_price->getProductPrices($product_id);
}
public function getProductSeoUrls($product_id) {
$product_seo_url_data = array();
@@ -0,0 +1,40 @@
<?php
class ModelCatalogProductPrice extends Model {
public function addProductPrices($product_id, $data) {
if (isset($data['product_prices'])) {
foreach ($data['product_prices'] as $store_id => $prices) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_prices SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "', price = '" . (float)$prices['price'] . "', price_2 = '" . (float)$prices['price_2'] . "', price_3 = '" . (float)$prices['price_3'] . "'");
}
}
}
public function editProductPrices($product_id, $data) {
$this->db->query("DELETE FROM " . DB_PREFIX . "product_prices WHERE product_id = '" . (int)$product_id . "'");
if (isset($data['product_prices'])) {
foreach ($data['product_prices'] as $store_id => $prices) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_prices SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "', price = '" . (float)$prices['price'] . "', price_2 = '" . (float)$prices['price_2'] . "', price_3 = '" . (float)$prices['price_3'] . "'");
}
}
}
public function getProductPrices($product_id) {
$prices = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_prices WHERE product_id = '" . (int)$product_id . "'");
foreach ($query->rows as $row) {
$prices[$row['store_id']] = array(
'price' => $row['price'],
'price_2' => $row['price_2'],
'price_3' => $row['price_3']
);
}
return $prices;
}
public function deleteProductPrices($product_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "product_prices WHERE product_id = '" . (int)$product_id . "'");
}
}