Приветствую!
Есть модуль подбора по характеристикам. Автор @Designer. Хочу немного доработать его. Автор последние несколько месяцев отвечает только "Нет времени" и т.д. (заказывал у него).
В общем нужно:
1. добавить вывод атрибутов подобранных товаров.
2. вывод количества на складе подобранных товаров.
код функции:
### Подбор по атрибутам
public function tuckup() {
$this->load->model('catalog/tuckup');
$this->load->model('tool/image');
$json = array();
if (isset($this->request->get['product_id']) && isset($this->request->get['category_id']) && isset($this->request->get['attribute']) ) {
if (! is_array($this->request->get['attribute'])) {
$json['error'] = 'Не выбрана характеристика для подбора!';
}
if (! isset($json['error'])) {
$attributes = $this->request->get['attribute'];
$attribute_data = array();
if ($attributes) {
foreach ($attributes as $attribute) {
list($attribute_id, $text) = explode('_', $attribute);
$attribute_data[] = array('attribute_id' => $attribute_id, 'text' => $text);
}
}
$products = $this->model_catalog_tuckup->getTuckup($this->request->get['product_id'], $this->request->get['category_id'], $attribute_data);
foreach ($products as $product) {
if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
} else {
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$product['special']) {
$special = $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
$json['success'][] = array(
'product_id' => $product['product_id'],
'thumb' => $image,
'name' => $product['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'minimum' => $product['minimum'] > 0 ? $product['minimum'] : 1,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);
}
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
###
Т.е. нужно в $json['success'][] = array( передать ещё:
'attribute'
'stock'
как это сделать?
спасибо за помощь
DesDesignerigner