Post by Bobzor » Sun May 26, 2019 5:21 am

I am looking to provide a link on my site that takes the customer to a page that shows all the products across all categories given a specific attribute that those products are associated with. Visitors to the site can already refine their search by attribute within a category by using the attribute filter but this is not what I'm trying to accomplish. I've searched for an extension but can't fine anything (as far as I can tell) that matches this need. Anyone have any info or advice would be really appreciated.

Newbie

Posts

Joined
Wed May 08, 2019 4:01 am

Post by D3MO » Mon May 27, 2019 1:55 am

if you want to make it only with a link click you need to make it work with get parameter index.php ?route=page&attribute=x&attribute=y

Opencart Expert | voldemaras@gmail.com
Skype - programanija | Gtalk - voldemaras@gmail.com
Extensions for Opencart @ https://www.opencartextensions.eu / or Opencart Marketplace

Need Custom Module? debug third party module or simply have any question related to Opencart? feel free to contact directly for a live chat session:) - INSTANT LIVE CHAT


User avatar
Active Member

Posts

Joined
Mon Apr 04, 2011 6:57 am

Post by Bobzor » Tue Jun 04, 2019 4:16 am

From what I understand, you're saying to manipulate the url string? Odd thing is I've tried this but it doesn't return anything or if it does it only returns all items in all catagories (regardless of url string).
Maybe I misunderstood what you were saying though?

Thanks for the input.

Newbie

Posts

Joined
Wed May 08, 2019 4:01 am

Post by straightlight » Tue Jun 04, 2019 7:12 pm

Bobzor wrote:
Sun May 26, 2019 5:21 am
I am looking to provide a link on my site that takes the customer to a page that shows all the products across all categories given a specific attribute that those products are associated with. Visitors to the site can already refine their search by attribute within a category by using the attribute filter but this is not what I'm trying to accomplish. I've searched for an extension but can't fine anything (as far as I can tell) that matches this need. Anyone have any info or advice would be really appreciated.
This can be easily accomplished by showing all attributes associated by each products among each categories of each pages without the use of a query since a query is meant to pull specific results of a product among or without a specific category or sub-categories which is not what you're requesting in this case.

To do so, in catalog/controller/product/category.php file,

find:

Code: Select all

$data['products'][] = array(
add above:

Code: Select all

$product_attributes = $this->model_catalog_product->getProductAttributes($result['product_id']);
Then, find below:

Code: Select all

'product_id' => $result['product_id'],
add below:

Code: Select all

'attributes' => $product_attributes,
Then, in your category.twig file, you can add between:

Code: Select all

{% for product in products %}
and:

Code: Select all

{% endfor %}
this:

Code: Select all

{% if product.attributes %}
	{% for attribute in product.attributes %}
		... your theme code ...
	{% endfor %}
{% endif %}
Replace: … your theme code … part with your actual theme code.

Since you're also looking for presentative associations, you could also do the following in the TWIG file for e.g:

Code: Select all

{% if product.attributes %}
	Attribute: Yes
{% else %}
       Attribute: No
{% endif %}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Bobzor » Sun Jun 09, 2019 11:10 am

thank you for the code

Newbie

Posts

Joined
Wed May 08, 2019 4:01 am
Who is online

Users browsing this forum: nonnedelectari and 409 guests