Product related

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306009

Hi,

Is there a way to load related products on product page with some hikashop code?

Would like to create some view for related products only and do some customizations if possible...

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 31
  • Thank you received: 3
4 years 11 months ago #306010

hello
step 1 : create a new hikashop content module - > setting set relation : Related products
step 2 : go to hikashop setting -> display tab -> Product options section -> Modules under the product page = select a module Related products
step 3 : go to product and set a Related products (search product name show a product and select ->save)

Last edit: 4 years 11 months ago by p30yaran.
The following user(s) said Thank You: Philip

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306011

Please dont replay if you cant read question fully.

The question was how to show related products with php code and not through settings....

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
4 years 11 months ago #306014

@kyratn:

Well, I would have understood your OP and answered as p30yaran did... perhaps it wasn't so clear what you want, and no reason to be sort of harsh to him ;)

Also, p30yaran's method is generally valid in this case, too. Plus, as far as I understand you, you want to take the following additional steps:

4:
Create a view override of a product listing view file close enough to what you want through the Display -> Views menu in the HikaShop backend, e.g. for listing_img_title.php.
If an override for this view already exists (indicated by the trash bin in the views listing), give the new one a new name, e.g. listing_related.php, and save.

5.:
Edit this view to your liking, including all the PHP you want.

6:
Back to the module which you created following p30yaran, there with "Div" selected, find and pick your new view under "Layout type".


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
The following user(s) said Thank You: Philip, p30yaran

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306022

Hi,

I wasnt rude ar all and that still not the question i asking :)

I would like to know if there is a way to load related products data of the product via PHP CODE.

The issue is that we have some customization under listing_div.php and this is also included loading via module. For sure we could hide with css but maybe we could go cleaner way and load product related data as we do as example for product code:

$this->element->product_code

Doing var_dump for $this->element returns no data for related products. So i am curious where are they stored?

I hope question is more clear now.


Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 11 months ago #306018

Hi,

I would also recommend the same as lousyfool:
create a related products module (or use the one already pre created when you install HikaShop), do a view override (of product/listing_img_title.php or another view file of the products listing) and change the name of the view override so that you can then select that view override in the settings of the related products module so that only that module will use this custom view file.

Now, if you want to load related products data through PHP code to display them yourself, that's a lot more complex as you would need to do your own MySQL queries to load the related products and all their data (images, prices, discounts, badges, etc) and then some PHP code to display the listing yourself the way you want.

The following user(s) said Thank You: lousyfool

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306026

Hi,

1. Well that doesn't help. The issue is that that view is wrapped inside 3 other views. As we have done some modifications to listing_div.php view so some unwanted html which we use on product listings is also outputed...

Maybe there is some params we could use so if relation is set to related products via module settings do or not do something....??

2. Another thing we noticed that pagination is also displayed which shouldn't be for related products? Setting random items to "YES" does fix the issue....

All test done with protostar template with no modifcations to views.




Thanks

Attachments:
Last edit: 4 years 11 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 11 months ago #306031

Hi,

1. If you look at the code of listing_div, you can see this:

$itemLayoutType = $this->params->get('div_item_layout_type');	
...
$this->setLayout('listing_' . $itemLayoutType);
echo $this->loadTemplate();
That's the code which loads listing_img_title or listing_img_desc, etc based on the item layout setting of the menu item/module.
So you could modify product/listing.php, get the $itemLayoutType = $this->params->get('div_item_layout_type'); line of code to load the item layout of the module, and if it's your custom layout, then you could call listing_custom instead of listing_div in the line:
$html = $this->loadTemplate($layout_type);

2. Pagination is supported for modules under the product page so that if you have more related products than space available to display them, you can have a pagination to see all of them.
Now similarily to point 1, you could turn off the pagination if the item layout is your custom layout like that:
$this->config->set('pagination', '');

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306039

Thank you. That really helped!

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306049

Hi,

One more question.

Now if we have 2 products A, B and "Make product association in both ways" is active.

Adding product B to A as related product then A is added to B as related too. That's great!

But if we have 3 products A, B, C

Adding product B as related to product A and adding product C as related to product B there is no relation between pproduct C and A.

Maybe there is away via plugin or something to have all products which has some product related chain between them make them associated?

I hope you understand my question?

Just trying to avoid addinional clicks when creating products...

Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
4 years 11 months ago #306050

Hmmm... sorry, but I feel I need to "jump in" again... ;)

First of all, there's the question of how one defines a "related product".
In my head, it's more of an "accessory", good for upselling. E.g. if the "main" product is a computer, a mouse would be a related product. Vice versa, a computer would not be a related product for the mouse. "Related" defined this way calls for association in both ways to be disabled.
Different if "related" is interpreted as an alternative product. For a computer, this would be another computer model, and then association both ways makes good sense. In fact, then it's more like "from the same category".

Next, with the suggested way of associating = "auto-relating" not only two but multiple ways, it will not only become hard to impossible to manage but, latest when you add products D, E, F and more to the equation, it spells chaos or even disaster... if one won't pay super-carefully attention, sooner or later every product is related to every other. Think about it... think a few hundred or even more products in a store... OMG. You're asking for what's likely a time bomb!

Now, if for some reason this made sense in your use case, I'd say either develop a custom plugin matching it, or simply click few times more to have not only A<->B and B<->C, but also A<->C.

Actually, I would strongly oppose to have such option getting even only close to a store, not only due to my one-way interpretation (and use) of "related", but also because it's hell in a handcart to clean up and reorganise many wrong or unwanted two-way relations.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #306051

Hi,

Well, yes you right. That could lead to some issues based on what it need for. :)

As there is no made option we are trying to use it as product color thumbs. So user could navigate btw same product with different colors.

So i am pretty sure i wouldn't add shoes to dress as related product....

We will add it as related product only which has same name. As example having 3 products: Dress blue, dress red, dress black

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
4 years 11 months ago #306052

Ah ok.
That's what I'd call "variants", or "the closest alternative possible", haha...

Anyway, and as you figured out, also for this use case, with a "multi-to-multi" relationship it's likely for a human to quickly lose control and to cause havoc.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Last edit: 4 years 11 months ago by lousyfool. Reason: typo

Please Log in or Create an account to join the conversation.

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 11 months ago #306078

Hi,

Doing something to group products with similar names as related products of each other would indeed require the development of a custom plugin.
If you don't have too many products, handling that by hand might be faster than taking the time to develop such plugin.

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 1
1 year 3 months ago #348377

Hi,
I followed the instructions step by step, but the result is that I don't only see the related product module, but it looks like the site in the mobile version (two logos, the search, two menus) then below I find the module! can you help me to solve? the site is online! and from the link I write you can verify!!
problem on my site

Please Log in or Create an account to join the conversation.

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
1 year 3 months ago #348379

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 1
1 year 3 months ago #348389

solved!! thanks!!!

Please Log in or Create an account to join the conversation.

Time to create page: 0.126 seconds
Powered by Kunena Forum