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. :)


All times are GMT -8. The time now is 05:27 AM.

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