Answer the question
In order to leave comments, you need to log in
How to display links to OCFilter categories in the product card of OpenCart 2.3?
Hello. The well-known OCFilter filtering module is installed on the site. Landing pages are created with it. Question: how to display on the product card page links to the landing pages to which this product belongs?
There is a code to display these links in categories:
catalog/controller/product/category.php
$data['ocfilter_pages'] = array();
$this->load->model('catalog/ocfilter');
$ocfilter_pages = $this->model_catalog_ocfilter->getPages();
foreach ($ocfilter_pages as $ocfilter_page) {
if ($ocfilter_page['category_id'] != $category_id) {
continue;
}
if (isset($this->request->get['path'])) {
$link = rtrim($this->url->link('product/category', 'path=' . $this->request->get['path']), '/');
} else {
$link = rtrim($this->url->link('product/category', 'path=' . $ocfilter_page['category_id']), '/');
}
if ($ocfilter_page['keyword']) {
$link .= '/' . $ocfilter_page['keyword'];
} else {
$link .= '/' . $ocfilter_page['params'];
}
if ($this->config->get('config_seo_url_type') == 'seo_pro') {
$link .= '/';
}
$data['ocfilter_pages'][] = array(
'text' => $ocfilter_page['title'],
'selected' => (!empty($ocfilter_page_info) && $ocfilter_page_info['ocfilter_page_id'] == $ocfilter_page['ocfilter_page_id']),
'href' => $link
);
}
<?php if (!empty($ocfilter_pages)) { ?>
<hr />
<ul class="list-inline">
<?php foreach ($ocfilter_pages as $ocfilter_page) { ?>
<li>
<?php if ($ocfilter_page['selected']) { ?>
<strong><?php echo $ocfilter_page['text']; ?></strong>
<?php } else { ?>
<a href="<?php echo $ocfilter_page['href']; ?>"><?php echo $ocfilter_page['text']; ?></a>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
if ($ocfilter_page['category_id'] != $category_id) {
continue;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question