View Single Post
  #1  
Old 08-24-2006, 03:44 AM
 
salsabeel salsabeel is offline
 

Senior Member
  
Join Date: Jan 2004
Posts: 132
 

Arrow Help Requested on Great Deals Mod

Hello everyone,

I am trying to create a custom mod for Great Deals that will work similar to the Featured Products mod for X-Cart. In order to select Great Deals from all products in the database and save it in a new table in the database, I called it great_products. This table is like featured_products. In featured products we select the product to mark as featured from the admin area. There is no problem with me for this step because I can save the product into great_products table by SQL code. The problem is when I want to show these products in our site like we do with featured products.

Below are the steps I have done.

1. Create great_products table by using the following SQL code:

Code:
CREATE TABLE `xcart_great_products` ( `productid` int(11) NOT NULL default '0', `categoryid` int(11) NOT NULL default '0', `product_order` int(11) NOT NULL default '0', `avail` char(1) NOT NULL default 'Y', PRIMARY KEY (`productid`,`categoryid`), KEY `product_order` (`product_order`), KEY `avail` (`avail`), KEY `pacpo` (`productid`,`avail`,`categoryid`,`product_order`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

2. Insert some products into great_products table by using the following SQL code:

Code:
INSERT INTO `xcart_great_products` (`productid`, `categoryid`, `product_order`, `avail`)VALUES (154, 0, 50, 'Y'), (461, 0, 60, 'Y'), (480, 0, 80, 'Y');

3. Create a new template page (great.tpl) in skin1/customer/main/

Code:
{capture name=dialog} {if $g_products ne ""} {if $total_pages gt 2} <br> { include file="customer/main/navigation.tpl" } {/if} {include file="customer/main/products.tpl" products=$g_products featured="Y"} {if $total_pages gt 2} <br> { include file="customer/main/navigation.tpl" } {/if} {else} {$lng.txt_no_featured} {/if} {/capture}

4. Create great_products.php

Code:
| | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: <a href="<a href="http://www.x-cart.com/license.php" target="_blank" onclick="return top.js.OpenExtLink (window,event,this)">http://www.x-cart.com/license.php</a>" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> <a href="http://www.x-cart.com/license" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.x-cart.com/license</a>.php</a> | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2005 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: great_products.php,v <a href="<a href="http://1.2.2.16" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://1.2.2.16</a>" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"><a href="http://1.2.2.16" target="_blank" onclick="return top.js.OpenExtLink (window,event,this)">1.2.2.16 </a></a> 2005/07/11 07:23:06 max Exp $ # # Get featured products data and store it into $f_products array # Get new products data and store it into $new_products array # if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); } # # Select from featured products table # $user_account['membership'] = !empty($user_account['membership'])?$user_account['membership']:""; $old_search_data = $search_data["products"]; $old_mode = $mode; $old_page = $page; $search_data["products"] = array(); $search_data["products"]["forsale"] = "Y"; $search_data["products"]["sort_condition"] = "$sql_tbl[great_products].product_order"; $from_tbl[$sql_tbl['great_products']] = 1; $search_condition = "$sql_tbl[products].productid=$sql_tbl[great_products].productid AND $sql_tbl[great_products].avail='Y' AND $sql_tbl[great_products].categoryid='".intval($cat)."' AND "; $REQUEST_METHOD = "GET"; $mode = "search"; include $xcart_dir."/include/search.php"; $search_data["products"] = $old_search_data; x_session_save("search_data"); $mode = $old_mode; $page = $old_page; if (!empty($active_modules["Subscriptions"])) { include_once $xcart_dir."/modules/Subscriptions/subscription.php"; } $smarty->clear_assign("products"); $smarty->assign("navigation_script","home.php?sort=$sort&sort_direction=$sort_direction"); $smarty->assign("g_products",$products); $search_data = ''; $products = array(); unset($search_data, $products); ?>

4. In welcome.tpl, before:

Code:
{include file="customer/main/featured.tpl" f_products=$f_products}

I added:

Code:
{include file="customer/main/great.tpl" g_products=$g_products}

5. In home_main.tpl I added:

Code:
{elseif $main eq "catalog" and $current_category.category eq ""} {include file="customer/main/welcome.tpl" g_products=$g_products}

But there is an error or something missing. I don't know what because when I test these changes no great products is appear.

Any help that can be offered is greatly appreciated! If what I am asking is not clear just let me know and I will try to further explain. Thanks in advanced!
__________________
X-Cart Platinum 4.6.5
Reply With Quote