Zen Cart Logo
Forums / General Questions / also purchased query question

also purchased query question

Locked

Views: 3,365

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
4 Apr 2007, 3:44 PM
#1
ryanf avatar

ryanf

New Zenner

Join Date:
Mar 2007
Posts:
32
Plugin Contributions:
0

also purchased query question

Hello, I have a question on how the also purchased gets it's results. Does it just grab the first four products that where bought with the particular product it?

If so, how would I change it to grab the most popular items that were also purchased with the particular item. Is that possible?

Thanks

4 Apr 2007, 3:48 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: also purchased query question

There isn't an override for this but you could customize the define for:

DEFINE('SQL_ALSO_PURCHASED', "select p.products_id, p.products_image
                     from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, "
                            . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p
                     where opa.products_id = '%s'
                     and opa.orders_id = opb.orders_id
                     and opb.products_id != '%s'
                     and opb.products_id = p.products_id
                     and opb.orders_id = o.orders_id
                     and p.products_status = 1
                     group by p.products_id
                     order by o.date_purchased desc
                     limit " . MAX_DISPLAY_ALSO_PURCHASED);

This is located in the:
/includes/classes/db/mysql/define_queries.php

You would need to reconstruct how that query is done and your criteria that you want to use ...

4 Apr 2007, 4:35 PM
#3
ryanf avatar

ryanf

New Zenner

Join Date:
Mar 2007
Posts:
32
Plugin Contributions:
0

Re: also purchased query question

Yeah I saw that, I was hoping someone knew the sql to enter.

7 Apr 2007, 3:17 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: also purchased query question

It grabs however many you set in the Maximum settings based on the date:

                     order by o.date_purchased desc
                     limit " . MAX_DISPLAY_ALSO_PURCHASED);  

You could try to work in the field products_ordered and see if that gives you a better selection than by date ...

NOTE: advantage of date is that when products come and go you are looking at more recent products based on recent orders ...

12 Apr 2007, 6:59 AM
#5
vivaraquel avatar

vivaraquel

Zen Follower

Join Date:
Sep 2004
Location:
Australia
Posts:
305
Plugin Contributions:
0

Re: also purchased query question

I have a question in regards to the display images in the also purchased box.

I have it set so they display horizontally, 4 per row. But they are coming up vertically in a sigle column.

I set it in Configuration > Product Info > Also Purchased Products Columns per Row > 4.

Is there somewhere else that I need to set it?

6 Oct 2007, 7:53 AM
#6
erwin208 avatar

erwin208

New Zenner

Join Date:
Nov 2005
Posts:
44
Plugin Contributions:
0

Re: also purchased query question

is there a way to reset "Also Purchased" to 0.

By making some test orders I have some strange combinations...

27 Oct 2007, 11:03 AM
#7
craigw avatar

craigw

New Zenner

Join Date:
Aug 2007
Posts:
36
Plugin Contributions:
0

Re: also purchased query question

I'm assuming you have done the test orders before you have made the site live.

I just go into Tools - Store Managerand click on Reset ALL Products Ordered to fix problems like that before making the site live.

On a new site, I also disable "Also Purchased Products" until I get enough orders in for it to be useful. Disabled by Configuration - Product Info & set "Also Purchased Products Columns per Row" = 0

27 Oct 2007, 12:33 PM
#8
spbennett avatar

spbennett

Zen Follower

Join Date:
Feb 2007
Location:
Leicester UK
Posts:
230
Plugin Contributions:
0

Re: also purchased query question

erwin208:

is there a way to reset "Also Purchased" to 0.

By making some test orders I have some strange combinations...

Delete your test orders and they won't affect the module any longer.

19 Sep 2008, 6:52 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: also purchased query question

What value do you have on the Configuration ... Maximum Values ...

Also Purchased Products
Number of products to display in the 'This Customer Also Purchased' box

In your tpl_products_info_display.php file do you have:

<!--bof also purchased products module-->
<?php require($template->get_template_dir('tpl_modules_also_purchased_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_also_purchased_products.php');?>
<!--eof also purchased products module-->

Also check in the Configuration ... Product Info ...

Also Purchased Products Columns per Row
Also Purchased Products Columns per Row
0= off or set the sort order

20 Sep 2008, 2:14 AM
#11
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: also purchased query question

I have cross sell and advanced cross sell installed. Upsell was installed with older cross sell.

This is weird. I cross sell 16 product of the same category together. Now I put item 1 in the cart and cross sell shows me the correct specified number (12 items in my case) below the cart. Good so far.

Now I click on one of the items below my cart, the ones offered by cross sell, and then add to cart as well.

Now I noticed some weird stuff. I have now 2 items in the cart and below I don't see the defined 12 items anymore but only 6!! Hey there should be plenty more to display as I set the number to 12 and have 16 products out of this category linked with each other.

What is going on? Why am I not seeing all my specified products defined in cross sell when more than one item is in the cart?

I add another item to the cart and then only 5 product show below. Strange...

I see the Also Purchased mod displaying items below as well.
Somehow the logic just doesn't make sense. Seems to be a conflict of some sorts between the two mods?

Anybody care to test? Add any items to the cart from this category and then add more items from the offered cross sell.
http://www.waxpottery.com/index.php?...ex&cPath=45_46

Just don't register or check out. Store is live.

1 Oct 2008, 2:59 PM
#12
lextechs avatar

lextechs

Zen Follower

Join Date:
Mar 2005
Location:
Tempe, AZ
Posts:
316
Plugin Contributions:
0

Re: also purchased query question

Ajeh:

What value do you have on the Configuration ... Maximum Values ...

In your tpl_products_info_display.php file do you have:

<!--bof also purchased products module--> <?php require($template->get_template_dir('tpl_modules_also_purchased_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_also_purchased_products.php');?> <!--eof also purchased products module-->
> 
> Also check in the Configuration ... Product Info ...

For my also purchase  i have max value at 6

This is what is in my tpl_product_info_display.php

<!--bof also purchased products module-->

<?php require($template->get_template_dir('tpl_modules_also_purchased_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_also_purchased_products.php');?>

<!--eof also purchased products module-->

Sorry the last posting i  pasted the wrong link here is the correct link tot he product where a customer purchase two different items

<http://www.lextechs.com/index.php?main_page=product_info&products_id=17197>

I am not sure if it has to do with the Tab mod or not
5 Jul 2009, 7:40 AM
#13
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: also purchased query question

I have mine set to show :
product info -> Also Purchased Products Columns per Row= 3

maximum values -> Also Purchased Products= 6

images -> Small Image Width= 135

I even tried removing ".centerBoxContentsAlsoPurch" from every style sheet not just the one I have for my theme and it did not do anything except remove the left space between the image and border.

I would like for them to be in a row not a column, I tried setting the product info to 0 and 1 but i still get a column and no row.

what do i need to do please

14 Aug 2009, 4:58 PM
#14
katrobb avatar

katrobb

New Zenner

Join Date:
Nov 2006
Posts:
45
Plugin Contributions:
0

Re: also purchased query question

Dear DarkAngel,
I don't know if you found an answer to your question, this worked for me.

Try adding this to your stylesheet:

**.centerBoxContentsAlsoPurch {
float:left;
**}

Good Luck,
Katrina Robb
https://www.KatalinaKlark.com

15 Aug 2009, 6:40 AM
#15
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: also purchased query question

no not fixed, still displaying in a column instead of in rows...I shall try this and see if it behaves...lol thanks and have a great weekend.

UPDATE*

wow that was faster than I usually am but wanted to say IT WORKED!!

sorry but some things need shouting. Now to put that code into a doc for safekeeping for the next time I change themes too...ty