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

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
+75 -7
View File
@@ -616,6 +616,25 @@ class ControllerCatalogProduct extends Controller {
);
$this->load->model('setting/store');
$stores = array();
$stores[] = array(
'store_id' => 0,
'name' => $this->language->get('text_default')
);
$store_results = $this->model_setting_store->getStores();
foreach ($store_results as $store) {
$stores[] = array(
'store_id' => $store['store_id'],
'name' => $store['name']
);
}
$data['stores'] = $stores;
$this->load->model('tool/image');
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
@@ -641,18 +660,34 @@ class ControllerCatalogProduct extends Controller {
}
}
$product_stores = $this->model_catalog_product->getProductStores($result['product_id']);
$product_prices = $this->model_catalog_product->getProductPrices($result['product_id']);
$prices_html = '';
foreach ($stores as $store) {
$store_id = $store['store_id'];
if (isset($product_prices[$store_id])) {
$p = $this->currency->format($product_prices[$store_id]['price'], $this->config->get('config_currency'));
$p2 = $this->currency->format($product_prices[$store_id]['price_2'], $this->config->get('config_currency'));
$p3 = $this->currency->format($product_prices[$store_id]['price_3'], $this->config->get('config_currency'));
$prices_html .= '<div style="margin-bottom:2px;"><small>' . $store['name'] . ':</small> ' . $p . ' / ' . $p2 . ' / ' . $p3 . '</div>';
}
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'image' => $image,
'name' => $result['name'],
'model' => $result['model'],
'price' => $this->currency->format($result['price'], $this->config->get('config_currency')),
'prices_html' => $prices_html,
'special' => $special,
'quantity' => $result['quantity'],
'status' => $result['status'] ? $this->language->get('text_enabled_short') : $this->language->get('text_disabled_short'),
'noindex' => $result['noindex'] ? $this->language->get('text_enabled_short') : $this->language->get('text_disabled_short'),
'href_shop' => HTTP_CATALOG . 'index.php?route=product/product&product_id=' . $result['product_id'],
'edit' => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $result['product_id'] . $url, true)
'edit' => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $result['product_id'] . $url, true),
'product_stores' => $product_stores
);
}
@@ -742,7 +777,6 @@ class ControllerCatalogProduct extends Controller {
}
$data['sort_name'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=pd.name' . $url, true);
$data['sort_model'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.model' . $url, true);
$data['sort_price'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.price' . $url, true);
$data['sort_quantity'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.quantity' . $url, true);
$data['sort_status'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.status' . $url, true);
@@ -1087,6 +1121,14 @@ class ControllerCatalogProduct extends Controller {
$data['product_store'] = array(0);
}
if (isset($this->request->post['product_prices'])) {
$data['product_prices'] = $this->request->post['product_prices'];
} elseif (isset($this->request->get['product_id'])) {
$data['product_prices'] = $this->model_catalog_product->getProductPrices($this->request->get['product_id']);
} else {
$data['product_prices'] = array();
}
if (isset($this->request->post['shipping'])) {
$data['shipping'] = $this->request->post['shipping'];
} elseif (!empty($product_info)) {
@@ -1685,10 +1727,6 @@ if (isset($this->request->post['price_3'])) {
}
}
if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
$this->error['model'] = $this->language->get('error_model');
}
if (isset($this->request->post['product_seo_url']) && is_array($this->request->post['product_seo_url'])) {
foreach ($this->request->post['product_seo_url'] as $store_id => &$languages) {
foreach ($languages as $language_id => &$keyword) {
@@ -1819,6 +1857,36 @@ if (isset($this->request->post['price_3'])) {
return !$this->error;
}
public function toggleStore() {
$json = array();
$this->load->model('catalog/product');
if (isset($this->request->get['product_id']) && isset($this->request->get['store_id'])) {
$product_id = (int)$this->request->get['product_id'];
$store_id = (int)$this->request->get['store_id'];
$product_stores = $this->model_catalog_product->getProductStores($product_id);
if (in_array($store_id, $product_stores)) {
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$store_id . "'");
$json['added'] = false;
} else {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
$json['added'] = true;
}
$this->cache->delete('product');
$json['success'] = true;
} else {
$json['error'] = true;
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function autocomplete() {
$json = array();