Size genel hattını 3x sürümleri için anlatayım.
catalog/controller/extension/module/fskcatproducts.php dosyasının içine
<?php
class ControllerExtensionModuleFskcatproducts extends Controller {
public function index() {
$category_list = array(5,1,8,20); // Buraya hangi kategoriler gelecekse onların adlarını yazın.
$products = $this->db->query("SELECT category_id,product_id FROM ".DB_PREFIX."product_to_category WHERE category_id IN(".implode(',',$category_list).") GROUP BY product_id")->rows;
$data['products'] = array();
$this->load->model('catalog/product');
foreach($products as $product){
$category_name = $this->db->query("SELECT name FROM ".DB_PREFIX."category_description WHERE category_id='".$product['category_id']."' AND language_id='".(int)$this->config->get('config_language_id')."'")->row['name'];
$result = $this->model_catalog_product->getProduct($product['product_id']);
if ($result['image']) {
$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_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$data['products'][$category_name][] = array(
'product_id' => $result['product_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' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}
return $this->load->view('extension/module/fskcatproduct', $data);
}
}Ardından
catalog/view/theme/TEMANIZ/template/extension/module/
fskcatproduct.twig dosyası oluşturun ve içine; *tasarımı vs size ait. Ben temeli vermek amacıyla yazıyorum. {% if products %}
{% for categoryName,productList in products %}
<div class="row">
<h2>{{categoryName}}</h2>
{% for product in productList %}
<div class="product-layout product-list col-xs-12">
<div class="product-thumb">
<div class="image"><a href="{{ product.href }}"><img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive" /></a></div>
<div>
<div class="caption">
<h4><a href="{{ product.href }}">{{ product.name }}</a></h4>
<p>{{ product.description }}</p>
{% if product.price %}
<p class="price"> {% if not product.special %}
{{ product.price }}
{% else %} <span class="price-new">{{ product.special }}</span> <span class="price-old">{{ product.price }}</span> {% endif %}
{% if product.tax %} <span class="price-tax">{{ text_tax }} {{ product.tax }}</span> {% endif %} </p>
{% endif %}
{% if product.rating %}
<div class="rating"> {% for i in 1..5 %}
{% if product.rating < i %} <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span> {% else %} <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>{% endif %}
{% endfor %} </div>
{% endif %} </div>
<div class="button-group">
<button type="button" onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">{{ button_cart }}</span></button>
<button type="button" data-toggle="tooltip" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product.product_id }}');"><i class="fa fa-heart"></i></button>
<button type="button" data-toggle="tooltip" title="{{ button_compare }}" onclick="compare.add('{{ product.product_id }}');"><i class="fa fa-exchange"></i></button>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
{%endif%}
[COLOR=#000000][FONT="Open Sans"][/FONT][/COLOR]
Şimdi modül hazır örneğin anasayfada kullanacaksanız
catalog/controller/common/home.php içinde $data['header'] = $this->load->controller('common/header'); sonrasına (tüm sayfalarda)
$data['fskcatproducts'] = $this->load->controller('[COLOR=#000000][FONT="Open Sans"]extension/module/fskcatproducts[/FONT][/COLOR]');şeklinde yazarak home.twig içinde {{
fskcatproducts}} ile erişebilirsiniz. Umarım faydalı olmuştur.