Рекомендуемые статьи и товары
This commit is contained in:
@@ -375,11 +375,23 @@ $data['price_n'] = $product_info['price'];
|
||||
|
||||
$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
|
||||
|
||||
if (!$results) {
|
||||
$results = $this->model_catalog_product->getRandomProductsFromSameCategories($this->request->get['product_id'], 4);
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
}
|
||||
|
||||
$product_images = $this->model_catalog_product->getProductImages($result['product_id']);
|
||||
|
||||
if ($product_images) {
|
||||
$additional_image = $this->model_tool_image->resize($product_images[0]['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$additional_image = false;
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
@@ -408,17 +420,57 @@ $data['price_n'] = $product_info['price'];
|
||||
$rating = false;
|
||||
}
|
||||
|
||||
$rent_prices = array_filter([$result['price'], $result['price_2']], function($price) {
|
||||
return (float)$price > 0;
|
||||
});
|
||||
|
||||
$min_price = $rent_prices ? min($rent_prices) : 0;
|
||||
|
||||
$data['products'][] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'product_id' => $result['product_id'],
|
||||
'thumb' => $image,
|
||||
'additional_thumb' => $additional_image,
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'price_n' => $result['price'],
|
||||
'price_2' => $this->currency->format($this->tax->calculate($result['price_2'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
|
||||
'price_2_n' => $result['price_2'],
|
||||
'price_3' => $this->currency->format($this->tax->calculate($result['price_3'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
|
||||
'price_3_n' => $result['price_3'],
|
||||
'min_price' => $this->currency->format($this->tax->calculate($min_price, $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $rating,
|
||||
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
|
||||
);
|
||||
}
|
||||
|
||||
$this->load->model('blog/article');
|
||||
|
||||
$data['articles'] = array();
|
||||
|
||||
$results = $this->model_blog_article->getArticleRelatedByProduct(array(
|
||||
'product_id' => $this->request->get['product_id'],
|
||||
'limit' => 3
|
||||
));
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('configblog_image_article_width'), $this->config->get('configblog_image_article_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('configblog_image_article_width'), $this->config->get('configblog_image_article_height'));
|
||||
}
|
||||
|
||||
$data['articles'][] = array(
|
||||
'article_id' => $result['article_id'],
|
||||
'thumb' => $image,
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $rating,
|
||||
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
|
||||
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('configblog_article_description_length')) . '..',
|
||||
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
|
||||
'viewed' => $result['viewed'],
|
||||
'href' => $this->url->link('blog/article', 'article_id=' . $result['article_id'])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user