В общем скачал модуль , который проверяет кол-во на складе , и если на складе 0 , ставит статус из карточки товара.
Написан для всех стандартных модулей
Часть кода для стандартного модуля:
</add>
</operation>
</file>
<file name="catalog/controller/module/bestseller.php">
<operation>
<search position="before" error="skip"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA[$stock_status = $result['stock_status'];
$stock_qty = $result['quantity'];]]></add>
</operation>
<operation>
<search position="after" offset="4" error="skip"><![CDATA[$this->data['products'][] = array(]]></search>
<add><![CDATA['stock_status' => $stock_status,
'stock_qty' => $stock_qty,]]></add>
</operation>
</file>
<file name="catalog/view/theme/default/template/module/bestseller.tpl">
<operation>
<search position="replace" error="skip"><![CDATA[<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />]]></search>
<add><![CDATA[<?php
if ($product['stock_qty'] <= 0) {
echo "<span style=\"color: #CC5800; font-size: 16px;\"><span class=\"outofstock\">" . $product['stock_status'] . "</span></span>";
} else {
echo "<input type=\"button\" value=\"" . $button_cart . "\" onclick=\"addToCart('" . $product['product_id'] . "');\" class=\"button\" />";
}
?>
]]>
Но я добавил еще один модуль "Карусель продуктов" , и переделываю по аналогии. В catalog/controller/module/product_carousel.tpl прописал
</operation>
</file>
<file name="catalog/view/theme/default/template/module/product_carousel.tpl">
<operation>
<search position="replace" error="skip"><![CDATA[<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />]]></search>
<add><![CDATA[<?php
if ($product['stock_qty'] <= 0) {
echo "<span style=\"color: #CC5800; font-size: 16px;\"><span class=\"outofstock\">" . $product['stock_status'] . "</span></span>";
} else {
echo "<input type=\"button\" value=\"" . $button_cart . "\" onclick=\"addToCart('" . $product['product_id'] . "');\" class=\"button\" />";
}
?>
]]>
Тут проблем нет , а вот в product_carousel.php получается 3 case. Меняю везде по аналогии , и в Новых товарах и в акциях работает , а в Рекомендуемые не работает , вобще не показывается кнопка.
Новые товары:
case 2:
$data = array(
'sort' => 'p.date_added',
'order' => 'DESC',
'start' => 0,
'limit' => $this->data['limit']
);
$results = $this->model_catalog_product->getProducts($data);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $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')));
} 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')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}
$stock_status = $result['stock_status'];
$stock_qty = $result['quantity'];
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'stock_status' => $stock_status,
'stock_qty' => $stock_qty,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
//Get the title from the language file
$this->data['heading_title']=$this->language->get('heading_title_latest');
}
break;
Акции:
case 3:
$data = array(
'sort' => 'pd.name',
'order' => 'ASC',
'start' => 0,
'limit' => $setting['limit']
);
$results = $this->model_catalog_product->getProductSpecials($data);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $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')));
} 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')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}
$stock_status = $result['stock_status'];
$stock_qty = $result['quantity'];
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'stock_status' => $stock_status,
'stock_qty' => $stock_qty,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
//Get the title from the language file
$this->data['heading_title']=$this->language->get('heading_title_special');
}
break;
default:
break;
Тут все хорошо , а вот case1 , вставил все по аналогии , но тут не появляется даже кнопка
case 1:
$products = explode(',', $this->config->get('featured_product'));
//print_r($products);exit;
$products = array_slice($products, 0, (int)$this->data['limit']);
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $product_info['rating'];
} else {
$rating = false;
}
$stock_status = $result['stock_status'];
$stock_qty = $result['quantity'];
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'stock_status' => $stock_status,
'stock_qty' => $stock_qty,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
);
//Get the title from the language file
$this->data['heading_title']=$this->language->get('heading_title_featured');
}
}
break;
Вот тут не работает. И ошибку еще выдает
2014-01-28 12:48:19 - PHP Notice: Undefined variable: result in /catalog/controller/module/product_carousel.php on line 66
2014-01-28 12:48:19 - PHP Notice: Undefined variable: result in /catalog/controller/module/product_carousel.php on line 67
$stock_status = $result['stock_status'];
$stock_qty = $result['quantity'];
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'stock_status' => $stock_status,
'stock_qty' => $stock_qty,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
);
//Get the title from the language file
$this->data['heading_title']=$this->language->get('heading_title_featured');
}
}
break;
Рекомендуемые , это case1. Помогите разобраться.