X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   list all products (https://forum.x-cart.com/showthread.php?t=910)

funkydunk 12-09-2002 09:09 AM

list all products
 
Anyone know how to put an extra page in that lists all products from all categories?

Cheers

okdpminc 12-09-2002 04:11 PM

Hey, that would be great! We could also use that to create a .PDF catalog of all our items. Hope somebody replies. :)

B00MER 12-09-2002 04:59 PM

Hate to sound like an idiot, but can you be a bit more specific?

funkydunk 12-09-2002 10:44 PM

Quote:

Originally Posted by B00MER
Hate to sound like an idiot, but can you be a bit more specific?


Hi Boomer,

I am building a shop and they require one page that lists all products, no matter what category the product is in. Ideally this would have a few other details as follows:

SKU | Item Description | Category | Link to view | Add to Cart ??

I know someone did something like this for a printable product list but could find it on the forum.

Thanks

cyberactive 12-09-2002 11:08 PM

Here's my php code to create a product list.

I've made a seperate php file for this. But I don't know how to integrate it into the look and feel of X-cart....

Code:

<TABLE ALIGN=CENTER VALIGN=TOP WIDTH=100%>
<? $db = mysql_connect("address","username","password");
mysql_select_db("datasename",$db);
$cats = mysql_query("SELECT * FROM xcart_categories order by category");
    while ($row1 = mysql_fetch_array($cats))
    {   
    $currentcat = $row1["category"];
echo "
<tr>
  <td>
 
  </td>
</tr>
<tr>
  <td width=\"300\">
  <font face=\"arial\">$currentcat:</font>
  </td>
</tr>
";
      $result = mysql_query("SELECT xcart_categories.category, xcart_pricing.price, xcart_products.product, xcart_products.descr FROM (xcart_categories INNER JOIN xcart_products ON xcart_categories.categoryid=xcart_products.categoryid) INNER JOIN xcart_pricing ON xcart_pricing.productid=xcart_products.productid WHERE xcart_categories.category = \"$currentcat\"");
      while ($myrow = mysql_fetch_array($result))
        {
      $product = $myrow["product"];
      $prijs = $myrow["price"];
      $desc = $myrow["desc"];

echo "

<tr>
  <td>
  <font face=\"arial\">$product</font>
  </td>
  <td width=\"100\" align=\"right\">
  <font face=\"arial\">$prijs</font>
  </td>
</tr>
";
        }
  }
?>
</table>


funkydunk 12-09-2002 11:14 PM

Thankyou.

I will be able to sort this now - cheers for the code.

funkydunk 12-10-2002 12:46 AM

Sorted.

Had to create a new php file based upon home.php. I called it list_all.php

Code:

<?

require "../smarty.php";
require "../config.php";
@include "./https.php";
require "./auth.php";

require "../include/categories.php";

require "./all_products.php";

#
# Assign Smarty variables and show template
#

$smarty->assign("main","listall");
$smarty->assign("location",$location);
$smarty->display("customer/list_all.tpl");
?>


This includes another file based upon products.php
Code:

<?
#
# Get products data for all categories and store it into $products array
#
$search_query = "($sql_tbl[products].categoryid='%' or $sql_tbl[products].categoryid1='%' or $sql_tbl[products].categoryid2='%' or $sql_tbl[products].categoryid3='%') and $sql_tbl[products].forsale='Y' group by $sql_tbl[products].productid order by $sql_tbl[categories].category asc";

$products = func_search_products($search_query, $user_account['membership']);

$smarty->assign("products",$products);
$smarty->assign("navigation_script","total_list.php?main=listall");
?>


It also includes a template customer/list_all.tpl which is identical to home.tpl except that I hard coded the page title.

customer/home_main.tpl was amended by adding:

Code:

{elseif $main eq "listall"}
{include file="customer/main/show_all.tpl"}


and creating a template as customer/main/show_all.tpl
This is effectively the original product listing in customer/main/product.tpl but I split it out so that I could show additional columns such as the category name and also to add the dialog box. I could be bothered to fully integrate this part. You will see what I mean when you run it.



funkydunk 12-10-2002 12:48 AM

forgot to say that the file is called by going to yourdomain.com/total_list.php?main=listall

Also that I have sorted it by category name but this can be changed by amending the sql order by code in all_products.php.

cyberactive 12-10-2002 01:02 AM

Wow Funkydunk.

You've completed the script.
Now I'll try to implement it....

Cool :P

funkydunk 12-10-2002 01:05 AM

cyberactive,

It doesnt split by category like your list did but it is integrated. :)

cyberactive 12-12-2002 04:12 AM

I'm not a programmer, and I've tried the above code....

But I realy don't understand what to do and which files to create....
Please give me some more details on this....

funkydunk 12-12-2002 04:38 AM

ok here goes...

total_list.php in the customer directory (not under skin1)
Code:

<?

require "../smarty.php";
require "../config.php";
@include "./https.php";
require "./auth.php";

require "../include/categories.php";

require "./all_products.php";

#
# Assign Smarty variables and show template
#

$smarty->assign("main","listall");
$smarty->assign("location",$location);
$smarty->display("customer/list_all.tpl");
?>


all_products.php in the same directory
Code:

<?
#
# Get products data for all categories and store it into $products array
#
$search_query = "($sql_tbl[products].categoryid='%' or $sql_tbl[products].categoryid1='%' or $sql_tbl[products].categoryid2='%' or $sql_tbl[products].categoryid3='%') and $sql_tbl[products].forsale='Y' group by $sql_tbl[products].productid order by $sql_tbl[categories].category asc";

// $search_query = "($sql_tbl[products].forsale='Y' group by $sql_tbl[products].productid order by $sql_tbl[products].orderby ".($config["General"]["product_order_reversed"]=="Y"?"desc":"asc").";

$products = func_search_products($search_query, $user_account['membership']);

$smarty->assign("products",$products);
$smarty->assign("navigation_script","total_list.php?main=listall");
?>



list_all.tpl in skin1/customer/ to:
Code:

{* $Id: list_all.tpl,v 1.2.2.1 2002/10/03 10:21:19 zorg Exp $ *}
{ config_load file="$skin_config" }
<html>
<head>
<title>{$lng.txt_site_title} :: All of Our Products</title>
{ include file="meta.tpl" }
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">
</head>
<body class="background">
{ include file="rectangle_top.tpl" }
{ include file="head.tpl" }

<table border=0 width=100% cellpadding=0 cellspacing=0 align="center">
<tr>
<td class=TableLeft width=150 valign=top>
{ include file="customer/categories.tpl" }
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu eq "Y"}
{ include file="modules/Bestsellers/menu_bestsellers.tpl" }
{/if}


{ include file="customer/menu_cart.tpl" }

{if $login eq "" }

{else}
{ include file="authbox.tpl" }
{/if}

{if $login eq "" }
{ include file="auth.tpl" }
{else}
{ include file="menu_profile.tpl" }
{/if}



{ include file="help.tpl" }


{ include file="poweredby.tpl" }
</td>
<td width=20></td>
<td valign=top>

{include file="customer/home_main.tpl"}


</td>
<td width=20></td>
</tr>
<tr>
<td class=TableLeft></td>
<td></td>
<td>{ include file="copyright.tpl" }
</td>
<td></td>
<td></td>
</tr>
</table>
{ include file="rectangle_bottom.tpl" }
</body>
</html>


and add the following code into home_main.tpl in skin1/customer above where it says:
{else}
{include file="common_templates.tpl"}
{/if}

Code:

{elseif $main eq "listall"}
{include file="customer/main/show_all.tpl"}


There is probably an easier way to do this but this worked for me.

Enjoy :wink:

cyberactive 12-12-2002 07:26 AM

Thanks for the quick reply.

Now something is happening:)

Code:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 5 bytes) in /home/httpd/vhosts/computerzaak.net/httpdocs/include/func.php on line 26

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 134 bytes) in Unknown on line 0


Hmmm.....
I called /total_list.php?main=listall

funkydunk 12-12-2002 07:28 AM

I think that the products array is too big for it to handle.

Will have to have a rethink. :(

cyberactive 12-12-2002 07:31 AM

Aha....:)

Well, it's about 800 products.

Let's think about it. :(

Jon 12-23-2002 03:27 PM

Would you not then need a template: customer/main/show_all.tpl ?

funkydunk 12-24-2002 12:21 AM

good spot Jon.

Just testing to see if anyone is reading the code :wink:

Yes customer/main/show_all.tpl should be created aswell:

I have extensively modified this but the basic template to use is products.tpl just I hard coded some of the dialog.tpl stuff

Code:

{* $Id: show_all.tpl,v 1.16 2002/09/25 10:12:05 zorg Exp $ *}
<font class="TableCenterNavigationPath">Shop Name</font>::<font class="TableCenterNavigationPath">All Products</font>::



This is the full list of products.



<TABLE border=0 cellPadding=2 cellSpacing=0 width="100%">
<TR>
<TD height="20" class=TableTop background="{$ImagesDir}/dialog_bg.gif" valign=bottom><FONT class=TableCenterPartnerPromotionTitleOrange>All Current Products</FONT></TD>
</TR>
<TR><TD class=DialogBorder><TABLE border=0 cellPadding=10 cellSpacing=0 width="100%">
<TR><TD bgColor=#FFFFFF>
{section name=product loop=$products}
<table border=0 width=100%  cellpadding=2 cellspacing=0>
<tr>
<td width=10% align=center valign=top >
{$products[product].category}
</td>
<td width=10% align=center valign=top >
{$products[product].productcode}
</td>
<td valign=top width=40% >
<font class=TableCenterProductTitleBlue>{$products[product].product|escape}</font>More....
</td>
<td width=20% align=center>
{if $active_modules.Subscriptions ne "" and $products[product].catalogprice}
{include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else}
{if $products[product].price ne 0}
{if $products[product].discount ne 0}
<font class=grey>Price ::<s>{math equation="(price/(100-discount))*100" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted}</s></font>

{/if}
<font class=grey>Price :: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}%{/if}
{else}
<font class=TableCenterProductTitleOrange>{$lng.lbl_enter_your_price}</font>
{/if}
{/if}
</td>
<form name=orderform_{%product.index%} method=post action="cart.php?mode=add">
<td align=center width=20%><a href="javascript: document.orderform_{%product.index%}.submit()">
{include file="buttons/add_to_cart.tpl"}</a>
<input type=hidden name=amount value=1>
<input type=hidden name=mode value=add>
<input type=hidden name=productid value="{$products[product].productid}">
<input type=hidden name=cat value="{$smarty.get.cat}">
<input type=hidden name=page value="{$smarty.get.page}">
</td>
</form>
</tr>
</table>
{/section}
</TD></TR>
</TABLE></TD></TR>
</TABLE>


okdpminc 03-28-2003 10:25 AM

Would someone please post a link to such a page so I can see the end result?

Thank you,

funkydunk 04-02-2003 01:29 AM

pm'd you with the link :D

okdpminc 04-02-2003 01:52 PM

Thank you! :)

BoomBoomBap 04-03-2003 11:24 AM

Well, it took a bit of customizing but I was able to implement this very succesfully.

Check it out: http://www.boomboombap.com/shop/customer/total_list.php?main=listall

Thanks much to FunkyDunk for this sweet mod !

BoomBoomBap 04-03-2003 11:26 AM

Hmm... someone I showed this to immediately replied with " Man you need to add pagination "

Any idea how to implement this ?

funkydunk 04-03-2003 12:44 PM

That wasn't the requirement that I was given for my client but the easiest thing to do is look at the exisitng products.php and adapt the coding in there.

May take some fiddling though. :wink:

ATKOgirl 04-03-2003 08:08 PM

You could just use this:

http://www.boomboombap.com/shop/customer/search.php?substring=


It is the search without a search term entered. In other words, what appears to be a bug, allowing you to enter a search without entering a term, turns out to be helpful, because it lists all products.

ATKOgirl

funkydunk 04-03-2003 10:18 PM

good point Atkogirl..blindingly obvious things are often missed looking for a solution. 8)

BoomBoomBap 04-03-2003 10:35 PM

Yes, this is the simple method.

I like FunkyDunk's however because of the nice "add to cart" feature and the simply and concise display :)

Im actually already using what you mention ATKOgirl with a button called "What's New"

StylinFX 06-05-2003 02:39 AM

I have tried and tried and tried this code.....All I get is a blank screen at the /total_list.php?main=listall

It shows my site layout side menu and head. But noting in the center of page complety blank.

Any thought!
:lol:

emf_electronics 06-07-2003 01:12 AM

this is perfect.. how would i implement this listing format in the product listing file(products.tpl) instead of the style that displays all the pictures that is standard setup with x-cart. not to display everything but just that category

adpboss 01-04-2004 12:21 PM

I am using this mod to create a page to be spidered by a product/price search engine and I am stuck.

The layout is simple and I have the display working perfect except for one thing.

The problem is that I need to display the category name of the ROOT category. Right now I am getting the subdirectory displayed as Cat1/Cat2/Cat3. I just need Cat1.

I am using {$products[product].category}. What SHOULD I be using to just get the root cat?

Thanks in advance for assistance. I know this is simple, but I am totally confused.

My show_all.tpl
Code:

<table>{section name=product loop=$products}
<tr>
<td>
{$products[product].product|escape}
</td>
<td>
{$products[product].price}
</td>
<td>
http://www.adpmods.com/xcart/customer/product.php?productid={$products[product].productid}
</td>
<td>
{$products[product].category}
</td>
</tr>{/section}
</table>


jeeya 01-04-2004 12:44 PM

.
 
It looks good in boomboombap's site. Only think I would like to suggest is to open up new small window saying added to cart or showing the cart, instead of on main page, taking to cart once we add the product.

adpboss 01-04-2004 12:47 PM

OK, I still need help. ^^^

Please.

adpboss 01-05-2004 09:56 AM

Bump for "I could really use some help please X-Pals".

Puleeze.

see two posts back.

funkydunk 01-05-2004 11:01 PM

This variable isn't available from the template without modifying func.php.

This can be done as follows (for 3.4 site)

change func_search_products where it says:
Code:

                if ($current_area == "C" && $store_language != $config["default_customer_language"])
                        $search_query = "select $sql_tbl[products].*, $sql_tbl[categories].category, min($sql_tbl[pricing].price) as price from $sql_tbl[pricing], $sql_tbl[categories], $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[pricing].quantity=1 and $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid $membership_condition and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') and $avail_condition ".$query.$tail;

                else
                        $search_query = "select $sql_tbl[products].*, $sql_tbl[categories].category, min($sql_tbl[pricing].price) as price from $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[categories] where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[pricing].quantity=1 and $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid $membership_condition and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') and $avail_condition ".$query.$tail;


to

Code:

                if ($current_area == "C" && $store_language != $config["default_customer_language"])
                        $search_query = "select $sql_tbl[products].*, $sql_tbl[categories].category, min($sql_tbl[pricing].price) as price from $sql_tbl[pricing], $sql_tbl[categories], $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[pricing].quantity=1 and $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid $membership_condition and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') and $avail_condition ".$query.$tail;
                else
                        $search_query = "select $sql_tbl[products].*, $sql_tbl[categories].category, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as maincat, min($sql_tbl[pricing].price) as price from $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[categories] where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[pricing].quantity=1 and $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid $membership_condition and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') and $avail_condition ".$query.$tail;


the top level category will then be available as:

{$products[product].maincat} in products.tpl

hth

adpboss 01-06-2004 09:38 AM

Thank you FD. You are my hero! =D>

funkydunk 01-06-2004 10:54 PM

Glad it worked :)

Darren 02-20-2004 08:56 AM

This is a great mod, but how would we add a thumbnail picture?

Thanks!

Quote:

Originally Posted by cyberactive
Here's my php code to create a product list.

I've made a seperate php file for this. But I don't know how to integrate it into the look and feel of X-cart....

Code:

<TABLE ALIGN=CENTER VALIGN=TOP WIDTH=100%>
<? $db = mysql_connect("address","username","password");
mysql_select_db("datasename",$db);
$cats = mysql_query("SELECT * FROM xcart_categories order by category");
    while ($row1 = mysql_fetch_array($cats))
    {   
    $currentcat = $row1["category"];
echo "
<tr>
  <td>
 
  </td>
</tr>
<tr>
  <td width=\"300\">
  <font face=\"arial\">$currentcat:</font>
  </td>
</tr>
";
      $result = mysql_query("SELECT xcart_categories.category, xcart_pricing.price, xcart_products.product, xcart_products.descr FROM (xcart_categories INNER JOIN xcart_products ON xcart_categories.categoryid=xcart_products.categoryid) INNER JOIN xcart_pricing ON xcart_pricing.productid=xcart_products.productid WHERE xcart_categories.category = \"$currentcat\"");
      while ($myrow = mysql_fetch_array($result))
        {
      $product = $myrow["product"];
      $prijs = $myrow["price"];
      $desc = $myrow["desc"];

echo "

<tr>
  <td>
  <font face=\"arial\">$product</font>
  </td>
  <td width=\"100\" align=\"right\">
  <font face=\"arial\">$prijs</font>
  </td>
</tr>
";
        }
  }
?>
</table>



nerd luv 06-01-2004 12:51 PM

Wonderful and much needed mod. Thank you much!

WPOO 09-21-2004 12:28 PM

mod not working for me with 4.03
 
When i installed de mod and go to the following url

www.mydomain.com/customer/total_list.php?main=listall

i get

Not Found
The requested URL /customer/index.php was not found on this server.

that is correct because there is no index.php in customer.

anyone know why it wants to go to index.php

Jon 09-21-2004 12:34 PM

^ Your using x-cart 4, I believe this mod is for x-cart 3.

deonya 09-24-2004 08:42 PM

I used this I have x-cart 4

<FORM method="POST" action="search.php" name="showall">
<INPUT type="hidden" name="mode" value="search">
<INPUT type="hidden" name="posted_data[by_title]" value="Y">
<INPUT type="hidden" name="posted_data[by_shortdescr]" value="Y">
<INPUT type="hidden" name="posted_data[by_fulldescr]" value="Y">
<INPUT type="hidden" name="posted_data[substring]" size="16" value="">
Show all products{include file="buttons/search_head.tpl"}
</FORM>

I added it at the top of my site next to the drop down http://www.pixellab.biz


All times are GMT -8. The time now is 07:02 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.