CHECKOUT - Get category data of the entry products

  • Posts: 57
  • Thank you received: 4
9 years 3 months ago #187357

Hi,

Can you help me please?
Hi need to get all the information of the categories of products inserted to use (for example) category namekey, category image or category name with the product information.

Can you help me how can I acess this data?

Hi have tried to access in "$this->element", "$this->rows", "$row", "$this->...") and don't find nothing about category.

Last edit: 9 years 3 months ago by rfernandes.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 3 months ago #187363

Hi,

On which page/view/file do you need to get that data ?

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

  • Posts: 57
  • Thank you received: 4
9 years 3 months ago #187471

In checkout page. More exact in cart.php to show the category image with the product image.

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

  • Posts: 26008
  • Thank you received: 4004
  • MODERATOR
9 years 3 months ago #187532

Hi,

Because a product can have several categories, this information is not load by default (in the listings).
So you need to load the categories of the listed product (using a SQL query).

Here some code from the product show

	$query = 'SELECT b.* FROM '.hikashop_table('product_category').' AS a LEFT JOIN '.hikashop_table('category').' AS b ON a.category_id = b.category_id WHERE a.product_id = '.(int)$prod->product_id.' ORDER BY a.product_category_id ASC';
	$database->setQuery($query);
	$categories = $database->loadObjectList();
	$this->assignRef('categories',$categories);
In your case you have to handle several product id depending the listing you have.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: rfernandes

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

  • Posts: 57
  • Thank you received: 4
9 years 3 months ago #187628

Thanks.

But for example, the product have a variable for default image, that image that you define that will show if you don't have a product image.
Maybe if we set that or if we create a session variable we can get after this variable.

For example, $variablename[$idproduct] = "xpto.jpg".

If we define an array where the idproduct define the position of the array and set there the image access maybe it will works.
What you think about that?

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

  • Posts: 26008
  • Thank you received: 4004
  • MODERATOR
9 years 3 months ago #187715

Hi,

I am sorry but I don't understand your last message regarding the previous discussion.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 57
  • Thank you received: 4
9 years 3 months ago #187788

Hi,

I have tried to said that maybe if we works with session variables maybe is better, but isn't because if we make a logout and return to the cart we don't have session variables so we don't have fields to override.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 3 months ago #187817

Hi,

You could indeed use $_SESSION to do that, but it's not perfect. If the user logs to his account and already has a cart for it and goes directly to the checkout, the $_SESSION array won't contain any product data and you won't be able to use the data coming from the product page.
Ideally, it would be safer to load again the data you need where you need it.

The following user(s) said Thank You: rfernandes

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

  • Posts: 57
  • Thank you received: 4
9 years 3 months ago #187943

Yes it's true.
I have saw this sittuation yesterday before report the last post.
Thanks for your attention I hope that this topic can help anothers users.

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

Time to create page: 0.068 seconds
Powered by Kunena Forum