How could I show name of variants in the category?

  • Posts: 2293
  • Thank you received: 315
7 years 7 months ago #251106

-- url of the page with the problem -- : par-store.ru
-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.6.2
-- PHP version -- : 5.6

I have products with variants.
All works fine but I curtious about one thing - how could I show the names of variants of product in the category view?



Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!
Attachments:

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

  • Posts: 81567
  • Thank you received: 13075
  • MODERATOR
7 years 7 months ago #251128

Hi,

The variants are not loaded there.
You would have to edit the file "listing_img_title" of the view "product" via the menu Display>Views and add:
- a MySQL query on the hikashop_product with a condition on product_parent_id = $this->row->product_id
- display the product_name of the results of that MySQL query.

The following user(s) said Thank You: progreccor

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

  • Posts: 1119
  • Thank you received: 114
7 years 7 months ago #251152

Hi,

What about characteristics? Is it possible to do same? To load one of the characteristics like Sizes as example...


Thank you

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

  • Posts: 2293
  • Thank you received: 315
7 years 7 months ago #251180

charachteristics is used to create variants of products, so this is the same thing


Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!

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

  • Posts: 81567
  • Thank you received: 13075
  • MODERATOR
7 years 7 months ago #251153

Hi,

Then I would ask what do you want to do with the characteristics ?
Do you want to display a list of all the possible values ?
Or a list of the values of the product ?
Or you actually want the dropdown to be connected with the add to cart button ?
If it's the first, it's fairly easy to do with a bit of customization. If it's the second, it's still fairly easy but will require a bit more work.
And if it's the later, it's quite complex to do and will require some strong PHP skills.

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

  • Posts: 1119
  • Thank you received: 114
7 years 7 months ago #251208

Hi,

We have clothes shop and we use color and sizes as characteristics. I would like to show possible sizes of the product in category listing. So buyer wouldn't need to go into product page to see if product has size he needs. This is what I am looking to have. If you could give me some quick code I could use I would customize it for my needs.

Thank you Nicolas.

Last edit: 7 years 7 months ago by kyratn.

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

  • Posts: 81567
  • Thank you received: 13075
  • MODERATOR
7 years 7 months ago #251259

Hi,

You'll have to run a MySQL query ( docs.joomla.org/Selecting_data_using_JDatabase ) on the tables hikashop_variant hikashop_product and hikashop_characteristic with the corresponding joins to load the possible values of each product. You can do that in the "listing_img_title" view file for each product.
Once you load the necessary data based on the $this->row->product_id, all that's left is displaying the characteristic_value of each row of your results array.
If you know a bit about PHP development and know MySQL, it shouldn't be a problem to do all that.

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

  • Posts: 1119
  • Thank you received: 114
7 years 6 months ago #251343

Hi,

Well after few hours of reading and trying I couldn't do it. If only php would be needed then I could handle it. Even sql would be fine but as it require to join 3 tables this is something I cant do as for now...
I also have tried to search forum but it looks like there is no one who tried to add it like I want....
So if someone could give me that my sql join code then I would be very thankful, otherwise I will have to leave it or to find someone who will do it for me.

Thanks

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

  • Posts: 4533
  • Thank you received: 612
  • MODERATOR
7 years 6 months ago #251350

Hello,

I'm not sure of understand what you mean but for your 3 tables,( without knowing your characteristics ) don't you have to create another table in order to rank value in simplified array ?
Because, so far I don't think you have php function to melt 3 array in one...
It's not a question of knowledge but of method, your algorithm must select your required values and includ it in a new array, like for example with your clothes size, the most little to the most tall and put it in a key like Product_available_size etc for all characteristics.

I can't really tell you more about this.

Hope you will be able to get what you looking for.


Regards

Last edit: 7 years 6 months ago by Philip.

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

  • Posts: 1119
  • Thank you received: 114
7 years 6 months ago #251357

Hi,

So with @kishoreweblabs help I have what I want. Looking into query I see what I was doing wrong...Thanks everyone for guiding and help.


p.s. new hikashop looks better :)

Last edit: 7 years 6 months ago by kyratn.

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

  • Posts: 1119
  • Thank you received: 114
7 years 6 months ago #251465

Hi,

This is the code i use and it works fine however i have 2 more small issues and i need help to resolve it as better as possible.

<!-- product characteristics values -->
<span class="listing-char listing-show-characteristics">
<?php 
$database = JFactory::getDBO();
$query="SELECT group_concat(product_id) as product_ids from `ozi8g_hikashop_product` WHERE (`product_id` = ".$this->row->product_id ." OR product_parent_id=".$this->row->product_id.") and product_quantity>0 ";
$database->setQuery($query);
$parent_product_ids=$database->loadResult();
$query = 'select * from ozi8g_hikashop_variant as v left join ozi8g_hikashop_characteristic as c on v.variant_characteristic_id=c.characteristic_id where characteristic_parent_id=21 and variant_product_id in  ('.$parent_product_ids.') group by characteristic_id ORDER BY `c`.`characteristic_ordering` ASC';
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach($rows as $row){

echo $row->characteristic_value." ";;

}
?>
</span>
<!-- end -->

1. As you can see if quantity is 0 size characteristic will be hidden. How can i add another check so if it is unpublished it would be hidden too? I have tried to add something like "and product_published>0" but it doesnt work...

2. There is some clothes categories like pantyhose which has sizes 2, 3, 4 so i had to create different characteristic for it and ofcouse it has different ID. Should i create same query with that ID and exclude it based on category or this somehow can be connected in one?

Thanks

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

  • Posts: 81567
  • Thank you received: 13075
  • MODERATOR
7 years 6 months ago #251466

Hi,

1. The and product_published>0 should do the job as far as I can see.

2. If you only have one characteristic on each product, then you can remove the piece characteristic_parent_id=21 and and it will work regardless of the characteristic used in each product. Otherwise, yes, you need to change the id in the query based on the product/category.

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

  • Posts: 1119
  • Thank you received: 114
7 years 6 months ago #251543

Hi,

1. Yes, it works. I was adding to different view file...my bad...

2. I have 2 characteristics which are size and color for clothes like dress, shirts.... and 1 characteristic which is size for clothes like pantyhose.
So I understand I should create another query. Wouldn't to many queries slow down page or something?
How can I restrict query based on product category? I see problem like this. If product A is in category B but as new product he also is in category C so for few months he is in 2 categories. If I restrict to category B then in C it will not work. I hope I was clear enough with my question....

3. I see another issue with my query. If variant is default and has quantity 0 it still visible, and code "and product_quantity>0" does not do the job...How could I fix it?

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

  • Posts: 81567
  • Thank you received: 13075
  • MODERATOR
7 years 6 months ago #251546

Hi,

2. Well, the more queries you have the slower it gets, that's for sure. But it might not be perceptible. If it changes from 1.20 sec to 1.22 sec, it won't matter. So I would recommend to have a go at it and see if it really gets slower.
You can add a PHP check like that:
if($this->element->category_id ==XXX){
// do the queries for the category with the id XXX
}

3. You probably want to replace:
(`product_id` = ".$this->row->product_id ." OR product_parent_id=".$this->row->product_id.")
by:
(product_parent_id=".$this->row->product_id.")
so that you don't get the main product entries.

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

  • Posts: 1119
  • Thank you received: 114
7 years 6 months ago #251646

All works.

Thanks

Last edit: 7 years 6 months ago by kyratn.

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

Time to create page: 0.101 seconds
Powered by Kunena Forum