Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 General help me questions
 Parent-child products
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aprilynm
Starting Member

USA
33 Posts

Posted - December 26 2012 :  23:28:25  Show Profile  Reply with Quote
My product table has parent and child products in whatever order they were entered. For inventory, it would be great to have the parent and child products together. Can anyone help me write a query to return each parent product followed by its child products?

Thanks and happy holidays!

Aprilynm

Aprilynm

Edited by - aprilynm on December 26 2012 23:29:13

zachary
Starting Member

29 Posts

Posted - December 27 2012 :  01:45:58  Show Profile  Reply with Quote
Hi Aprilynm,

I got a script sample here, hope it helps:

You just need to put the script below in a ".asp" page & upload to your VPASP Root then you are able to test it.

<%option explicit%>
<%response.buffer=true%>
<!--#include file="shop$db.asp"-->
<%ShopOpenDatabase dbc%>
<%
displayproduct
sub displayproduct
dim sql,rs,selected
sql="select * from products where hassubproduct='Yes'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql, dbc, adOpenForwardOnly, adLockReadOnly
if not rs.eof then
do while not rs.eof
debugwrite "<b>"&rs("cname") &" - "& rs("ccode") &"</b>"
getchildproduct rs("catalogid")
rs.movenext
loop
end if
end sub

Sub getchildproduct(parentid)
dim sql2,rs2,selected
sql2="select * from products where highercatalogid = "&parentid
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.open sql2, dbc, adOpenForwardOnly, adLockReadOnly
if not rs2.eof then
do while not rs2.eof
debugwrite "     - " & rs2("cname") &" - "& rs2("ccode")
rs2.movenext
loop
end if
end sub
%>

<%ShopCloseDatabase dbc%>

Thanks
Zach
Go to Top of Page

aprilynm
Starting Member

USA
33 Posts

Posted - December 27 2012 :  15:14:43  Show Profile  Reply with Quote
Zach,

This did the trick. Thanks so very much!

April

Aprilynm
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00