Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Вопрос про вывод производителей в категориях


Recommended Posts

Доброе времени суток, есть вот икой модификатор, который выводит производителей в категории, все рилииет но не могу понять как вывести описание производителя. 

Думаю нужно бугдет подклюлить иблицу manufacturer_description 

 

	<file path="catalog/model/catalog/manufacturer.php">
		<operation error="skip">
			<search><![CDATA[public function getManufacturers($data = array()) {]]></search>
			<add position="before"><![CDATA[
public function getBrandsByCategoryId($category_id) {
    $query = $this->db->query("
		SELECT
			m.* 
		FROM
			" . DB_PREFIX . "product p 
		RIGHT JOIN " . DB_PREFIX . "product_to_category p2c ON 
			p.product_id = p2c.product_id 
		LEFT JOIN " . DB_PREFIX . "manufacturer m ON
			p.manufacturer_id = m.manufacturer_id
		WHERE 
			p2c.category_id = " . (int)$category_id . " AND 
			m.manufacturer_id IS NOT NULL
		GROUP BY m.manufacturer_id
    ");
    return $query->rows;
}   	
			]]></add>
		</operation>
	</file>
	
	<file path="catalog/controller/product/category.php">
		<operation error="skip">
			<search><![CDATA[$category_info = $this->model_catalog_category->getCategory($category_id);]]></search>
			<add position="before"><![CDATA[
$this->load->model('catalog/manufacturer');
$brands = $this->model_catalog_manufacturer->getBrandsByCategoryId($category_id);
$data['brands'] = array();
foreach ($brands as $brand) {
	$image = $brand['image'];
	$data['brands'][] = array(
		'name'			=> $brand['name'],
		'image'			=> $this->model_tool_image->resize($brand['image'], 180, 54),
		'href_brand'	=> $this->url->link('product/manufacturer/info',  'manufacturer_id=' . $brand['manufacturer_id'] . $url)
	);
}
			]]></add>
		</operation>
	</file>

 

Link to comment
Share on other sites


1 час назад, alexb сказал:

Доброе времени суток, есть вот икой модификатор, который выводит производителей в категории, все рилииет но не могу понять как вывести описание производителя. 

Думаю нужно бугдет подклюлить иблицу manufacturer_description 

 

 

	<file path="catalog/model/catalog/manufacturer.php">
		<operation error="skip">
			<search><![CDATA[public function getManufacturers($data = array()) {]]></search>
			<add position="before"><![CDATA[
public function getBrandsByCategoryId($category_id) {
    $query = $this->db->query("
		SELECT
			m.*, md.description 
		FROM
			" . DB_PREFIX . "product p 
		RIGHT JOIN " . DB_PREFIX . "product_to_category p2c ON 
			p.product_id = p2c.product_id 
		LEFT JOIN " . DB_PREFIX . "manufacturer m ON
			p.manufacturer_id = m.manufacturer_id
		LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON 
			(m.manufacturer_id = md.manufacturer_id AND md.language_id = '" . (int)$this->config->get('config_language_id') . "')
		WHERE 
			p2c.category_id = " . (int)$category_id . " AND 
			m.manufacturer_id IS NOT NULL
		GROUP BY m.manufacturer_id
    ");
    return $query->rows;
}   	
			]]></add>
		</operation>
	</file>
	
	<file path="catalog/controller/product/category.php">
		<operation error="skip">
			<search><![CDATA[$category_info = $this->model_catalog_category->getCategory($category_id);]]></search>
			<add position="before"><![CDATA[
$this->load->model('catalog/manufacturer');
$brands = $this->model_catalog_manufacturer->getBrandsByCategoryId($category_id);
$data['brands'] = array();
foreach ($brands as $brand) {
	$image = $brand['image'];
	$data['brands'][] = array(
		'name'			=> $brand['name'],
		'description'	=> $brand['description'],
		'image'			=> $this->model_tool_image->resize($brand['image'], 180, 54),
		'href_brand'	=> $this->url->link('product/manufacturer/info',  'manufacturer_id=' . $brand['manufacturer_id'] . $url)
	);
}
			]]></add>
		</operation>
	</file>

попробуйте ик, не проверял

ну и во вьюхе вывести description

  • +1 1
Link to comment
Share on other sites

Как-то ик:

SELECT
    m.*, md.description AS description
FROM
    " . DB_PREFIX . "product p
RIGHT JOIN " . DB_PREFIX . "product_to_category p2c ON
    p.product_id = p2c.product_id
LEFT JOIN " . DB_PREFIX . "manufacturer m ON
    p.manufacturer_id = m.manufacturer_id
LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON
    (m.manufacturer_id = md.manufacturer_id)
WHERE
    p2c.category_id = " . (int)$category_id . " AND 
    m.manufacturer_id IS NOT NULL AND 
    md.language_id = '" . (int)$this->config->get('config_language_id') . "'
GROUP BY
    m.manufacturer_id

и в $brand['description'] бугдет ваше описание бренда на выбранном языке

  • +1 1
Link to comment
Share on other sites

все рилииет, оба способа ))

При чем description выводится а вот поле которое я создал, и которое в тот же иблиэто нет, пишет Undefined index:name1, хотя все по аналогии и поля похожи и иблица иже manufacturer_description

Edited by alexb
Link to comment
Share on other sites


разобрался что нужно изменить m.*, md.description AS description

а как добавить еещё значение?

 

 

m.*, md.description AS description,
m.*, md.description1 AS description1

Edited by alexb
Link to comment
Share on other sites


1 минуту назад, alexb сказал:

разобрался что нужно изменить m.*, md.description AS description

а как добавить еещё значение?

 

 

m.*, md.description AS description,
m.*, md.description1 AS description1

 

SELECT
			m.*, md.description, md.name1 

 

и по-хорошему description прогнать через гдекодирование тегов.

'description'	=> html_entity_decode($brand['description'], ENT_QUOTES, 'UTF-8');

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.