Post by adibranch » Wed Jul 31, 2024 1:49 am

Hi all, 3.0.2.0 . I need to retrieve and display the subcategory meta description and display it in the subcat loop in the category page. I've cobbled together a number of things but none worked correctly. Can anyone help?

New member

Posts

Joined
Tue Jul 11, 2017 12:48 am

Post by grgr » Wed Jul 31, 2024 6:42 am

In ../controller/produc/category.php set the description to the maeta description?

Code: Select all

$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
Change to:

Code: Select all

$data['description'] = $category_info['meta_description'];
Alternatively set another variable and put it where you like in the template file.

-
Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by adibranch » Wed Jul 31, 2024 5:38 pm

Hi, thanks. That retrieves the main meta description, but i need to retrieve each subcategories meta desription and display it in the subcat display area.

New member

Posts

Joined
Tue Jul 11, 2017 12:48 am

Post by grgr » Wed Jul 31, 2024 8:19 pm

Oh, I see.
In which case you want edit this little bit here:

Code: Select all

	$data['categories'][] = array(
		'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
		'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
				);
As far as i remember it pulls all the category data so just add the meta description to the array()

Code: Select all

	$data['categories'][] = array(
		'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
		'meta_desc' -> $result['meta_description'],
		'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
		);
Then in the loop of your template you just use {{ meta_desc}} to show the description.

Then of course, wrap it up in a OCMOD or an event rather then editing the file.

-
Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK
Who is online

Users browsing this forum: No registered users and 20 guests