Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Ebay Auctionblox


Guest

Recommended Posts

I'm trying to get the auction listing genrator to display my oscommerce categories for each product so that generating a listing from a template is an easy task. AT the moment I can only sort by price, model or item name, These dont give me any great control to easy select all products from a single category to add to a listing template. Heres where I've got to at the moment with the generator code, but seeing as I'm not a coder it dosn't work as it should. Could someone take a look at the code and tell me where I'm going wrong, and why the categories aren't showing up. Thanks.

 

<?php
/*
 $Id: auction_generator.php,v 1.1.1.1 2004/09/22 14:35:47 auctionblox Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce
 
 This file is part of the eBay Auction Manager for osCommerce
 http://www.auctionblox.com/oscommerce

 Copyright (c) 2003, AuctionBlox.com  

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_FUNCTIONS . 'formatter.php');
 
 require(DIR_WS_CLASSES . 'auction_lister.php');
 $auctionLister = new auctionLister();

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 
 $auctionHelper = new auctionHelper();
 
 require(DIR_WS_CLASSES . 'auction_constants.php');
 $auctionConstants = new auctionConstants;
 
 $insuranceOptions = $auctionConstants->getInsuranceOptions();
 $shippingTypes = $auctionConstants->getShippingTypes();
 $listingTypes = $auctionConstants->getListingTypes();
 $sites = $auctionConstants->getSites();
 $durations = $auctionConstants->getListingDurations();
 $currencylist = $auctionConstants->getCurrencies();
 $shippingLocations = $auctionConstants->getShippingLocations();
 $regions = $auctionConstants->getRegions();
 $galleryOptions = $auctionConstants->getGalleryOptions();
 $storeCategories = $auctionLister->getStoreCategories();  
 $templates = $auctionLister->getTemplatesForDropdown();

 $searchterms=array(
	 array('id'=>"pd.products_name",'text'=>'Title'),
	 array('id'=>"p.products_model",'text'=>'Model'),
	 array('id'=>"cd.categories_name",'text'=>'Category'),
	 array('id'=>"p.products_price",'text'=>'Price'),
	 array('id'=>"p.products_last_modified",'text'=>'Last Modified'));
 
 if(isset($HTTP_GET_VARS['searchname']))
 {
  $search = array(
     "name" => $HTTP_GET_VARS['searchname'], 
   "value" => $HTTP_GET_VARS['searchvalue']);
 }

 if(isset($HTTP_GET_VARS['sortname']))
 {
  $sort = array(
     "name" => $HTTP_GET_VARS['sortname'], 
   "value" => $HTTP_GET_VARS['sortvalue']);
 }
 
 if($HTTP_GET_VARS['sortvalue'] == "desc") 
 {
	 $arrow_filename = "arrow_up_selected.gif";
$next_array = "asc";
 }
 else
 {
   $arrow_filename = "arrow_down_selected.gif";
$next_array = "desc";
 }
 
 $descriptions = array(
   array('id' => '{PRODUCTS_DESCRIPTION}', 'text' => TEXT_USE_PRODUCT),
   array('id' => '{DESCRIPTION}', 'text' => TEXT_USE_TEMPLATE));
 
 $products = $auctionLister->getProducts($HTTP_GET_VARS['page'], $split, $sort, $search);

 $checkAll = ((isset($HTTP_GET_VARS['check']) && $HTTP_GET_VARS['check'] === 'true') ? true : false);

  switch ($_REQUEST['perform']) 
  {
  case 'GenerateConfirm':
  $templateid = $_REQUEST['templateid'];
   $template = $auctionLister->getTemplate($templateid);

  // This will create an IN clause for the SQL query so that we
  // create only the items selected   
     $affectedItems = $auctionHelper->createAffectedItemsArrayOfOID($HTTP_POST_VARS);
  $in = implode(",", $affectedItems);
  
  $products_query_raw = "select p.*, pd.products_name, pd.products_description, pfs.domestic_shipping, pfs.domestic_shipping_addl from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd using (products_id) LEFT JOIN " . TABLE_PRODUCTS_FIXED_SHIPPING . " pfs using (products_id) where pd.language_id = " . (int)$languages_id . " and p.products_id in ($in)";
  $products_query = tep_db_query($products_query_raw);
  
  // This will overwrite any of the template variables with ones from the POST VARS
  $template2 = array_merge($template, $HTTP_POST_VARS);    
  $template2['products_id'] = '{PRODUCTS_ID}';
  if($HTTP_POST_VARS['description']=='{DESCRIPTION}')
   $template2['description']=$template['description'];

  $template=$template2;
     
  while ($product = tep_db_fetch_array($products_query)) 
  {
      $auctionLister->insertListing($template, $product);
  }
  tep_redirect(tep_href_link(FILENAME_AUCTION_SAVED));
  break; 

  case 'UploadConfirm':
  $templateid = $_REQUEST['templateid'];
   $template = $auctionLister->getTemplate($templateid);

  // This will create an IN clause for the SQL query so that we
  // create only the items selected   
     $affectedItems = $auctionHelper->createAffectedItemsArrayOfOID($HTTP_POST_VARS);
  $in = implode(",", $affectedItems);
  
  $products_query_raw = "select p.*, pd.products_name, pd.products_description, pfs.domestic_shipping, pfs.domestic_shipping_addl from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd using (products_id) LEFT JOIN " . TABLE_PRODUCTS_FIXED_SHIPPING . " pfs using (products_id) where pd.language_id = '" . (int)$languages_id . "' and p.products_id in ($in)";
  $products_query = tep_db_query($products_query_raw);
  
  // This will overwrite any of the template variables with ones from the POST VARS
  $template = array_merge($template, $HTTP_POST_VARS);
  $template['products_id'] = '{PRODUCTS_ID}';
  
  while ($product = tep_db_fetch_array($products_query)) 
  {
     $auctionLister->addToUpload($template, $product);
  }
  
  tep_redirect(tep_href_link(FILENAME_AUCTION_UPLOADS));
  break; 
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript">
function submit_form(perform)
{
 //alert(perform);
 document.forms['listings'].perform.value = perform;
 document.forms['listings'].submit();
 return false;
}

function selectcat(id)
{
 val = window.open('auction_categories_client.php?e='+id+'&s='+document['listings']['site'].value, 'categories', 'width=500, height=585, location=no, menubar=no, toolbar=no, status=no, resizable=yes, scrollbars=yes');
}

function changeSite()
{
 if((document['listings']['category1'] != null && document['listings']['category1'].value.length > 0) ||
    (document['listings']['category2'] != null && document['listings']['category2'].value.length > 0))
 {
	 alert('<?php echo TEXT_CATEGORIES_DIFFER ?>'); 
 }
 
 document['listings']['category1'].value = '';
 document['listings']['category2'].value = '';
}
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<!-- header //-->
<?php
 require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->


   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td colspan="2" width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="smallText" align="right"><?php $auctionHelper->drawSearchForm(FILENAME_AUCTION_GENERATOR, $searchterms); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr valign="top">
       <td>
	 <?php echo tep_draw_form("listings", FILENAME_AUCTION_GENERATOR, tep_get_all_get_params()) ?>
	 <table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr class="dataTableHeadingRow">
   <input type="hidden" name="perform" value="nothing">       
   <td>
<?      if ($checkAll === true)
  	 { echo ' <a class="dataTableHeadingContent" href="' . tep_href_link(FILENAME_AUCTION_GENERATOR, tep_get_all_get_params(array('check')) . 'check=false') . '">--</a>'; }
  	 else
  	 { echo ' <a class="dataTableHeadingContent" href="' . tep_href_link(FILENAME_AUCTION_GENERATOR, tep_get_all_get_params(array('check')) . 'check=true') . '">X</a>'; }
?>
   </td>
            <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_PRODUCT_TITLE, "pd.products_name");?></td>
            <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_PRODUCT_MODEL, "p.pd.products_name");?></td>
   <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_PRODUCT_CATEGORY, "cd.categories_name");?></td>
            <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_PRODUCTS_PRICE, "p.products_price");?></td>
            <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_DOMESTIC_SHIPPING, "pfs.domestic_shipping");?></td>
            <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_DOMESTIC_SHIPPING_ADDL, "pfs.domestic_shipping_addl");?></td>
            <td class="dataTableHeadingContent"><?php $auctionHelper->drawSortHeader(FILENAME_AUCTION_GENERATOR, TABLE_HEADING_PRODUCTS_LAST_MODIFIED, "p.products_last_modified");?></td>
             </tr>
<?php
for ($i = 0, $n = sizeof($products); $i < $n; $i++) 
{
?>	
             <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">
               <td class="dataTableContent" valign="top"><?php echo tep_draw_checkbox_field('oID-'.$products[$i]['products_id'],'', $checkAll); ?></td>
               <td class="dataTableContent"><?php echo $products[$i]['products_name']; ?></td>
               <td class="dataTableContent"><?php echo $products[$i]['products_model']; ?></td>
   <td class="dataTableContent"><?php echo $products[$i]['cd.categories_name']; ?></td>
               <td class="dataTableContent" align="right"><?php echo $currencies->format($products[$i]['products_price']); ?></td>
               <td class="dataTableContent" align="right"><?php echo $currencies->format($products[$i]['domestic_shipping']); ?></td>
               <td class="dataTableContent" align="right"><?php echo $currencies->format($products[$i]['domestic_shipping_addl']); ?></td>
               <td class="dataTableContent" align="right"><?php echo tep_date_short($products[$i]['products_last_modified']); ?></td>
               <?php //<td class="dataTableContent" align="right">?><?php echo $products[$i]['categories_name']; ?><?php //</td>?>
         </tr>
<?php
   }
?>
	 </table>    
<?php

 $heading = array();
 $contents = array();
 
 switch ($_REQUEST['perform']) {
   case 'GenerateListing':
  $templateid = $_REQUEST['templateid'];
   $template = $auctionLister->getTemplate($templateid);

     $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_GENERATE_LISTINGS . '</b>');

     $affectedItems = $auctionHelper->createAffectedItemsArrayOfOID($HTTP_POST_VARS);
     $contents[] = array('text' => sprintf(TEXT_INFO_GENERATE_LISTINGS, count($affectedItems)));
  
  $contents[] = array('align' => 'left', 
   'text' => tep_image_button("button_save.gif", IMAGE_SAVE, 'onclick="return submit_form(\'GenerateConfirm\');"') . ' ' );
//    . tep_image_button("button_upload.gif", IMAGE_UPLOAD, 'onclick="return submit_form(\'UploadConfirm\');"'));

     $contents[] = array('text' => tep_draw_hidden_field('templateid', $HTTP_POST_VARS['templateid'], ''));
     $contents[] = array('text' => ENTRY_TITLE . '<br>' . tep_draw_input_field('title', '{PRODUCTS_NAME}', 'maxlength="55"', false) . '<br>');
     $contents[] = array('text' => ENTRY_SUBTITLE . '<br>' . tep_draw_input_field('subtitle', '', 'maxlength="55"', false) . '<br>');
     $contents[] = array('text' => ENTRY_DESCRIPTION . '<br>' . tep_draw_pull_down_menu('description', $descriptions, '') . '<br>');
     $contents[] = array('text' => '<br>' . ENTRY_MINIMUM_BID . '<br>' . tep_draw_input_field('price', '{PRODUCTS_PRICE}', '', false) . '<br>');
     $contents[] = array('text' => ENTRY_BIN_PRICE . '<br>' . tep_draw_input_field('bin_price', '', '', false) . '<br>');
     $contents[] = array('text' => ENTRY_RESERVE_PRICE . '<br>' . tep_draw_input_field('reserve_price', '', '', false) . '<br><br>');
     $contents[] = array('text' => ENTRY_LISTING_TYPE . '<br>' . tep_draw_pull_down_menu('listing_type', $listingTypes, $template['listing_type']) . '<br>');
     $contents[] = array('text' => ENTRY_SITE . '<br>' . tep_draw_pull_down_menu('site', $sites, $template['site'], 'onchange="changeSite();"') . '<br>');
     $contents[] = array('text' => '<br>' . ENTRY_CATEGORY1 . '<br>' . tep_draw_input_field('category1', $template['category1'], '', false) . '<a href="#" onclick="selectcat(\'category1\');"><u>' . TEXT_CATEGORY_FIND . '</u></a><br>');
     $contents[] = array('text' => ENTRY_CATEGORY2 . '<br>' . tep_draw_input_field('category2', $template['category2'], '', false) . '<a href="#" onclick="selectcat(\'category2\');"><u>' . TEXT_CATEGORY_FIND . '</u></a><br>');
     $contents[] = array('text' => ENTRY_STORE_CATEGORY . '<br>' . tep_draw_pull_down_menu('store_category', $storeCategories, $template['store_category']) . '<br>');
     $contents[] = array('text' => ENTRY_DURATION . '<br>' . tep_draw_pull_down_menu('duration', $durations, $template['duration']) . '<br>');
     $contents[] = array('text' => ENTRY_QUANTITY . '<br>' . tep_draw_input_field('quantity', $template['quantity'], 'maxlength="5"', false) . '<br>');
  
  
     $contents[] = array('text' => '<br>' . ENTRY_SHIPPING_LOCATION . '<br>' . tep_draw_pull_down_menu('shipping_location', $shippingLocations, $template['shipping_location']));
     $contents[] = array('text' => ENTRY_SHIPPING_TYPE . '<br>' . tep_draw_pull_down_menu('shipping_type', $shippingTypes, $template['shipping_type']));
     $contents[] = array('text' => ENTRY_SHIPPING_FIRST_ITEM . '<br>' . tep_draw_input_field('shipping', '{DOMESTIC_SHIPPING}', '', false) . '<br>');
     $contents[] = array('text' => ENTRY_SHIPPING_ADDL_ITEM . '<br>' . tep_draw_input_field('shipping_addl', '{DOMESTIC_SHIPPING_ADDL}', '', false) . '<br>');
     $contents[] = array('text' => '<br>' . ENTRY_PICTURE1_URL . '<br>' . tep_draw_input_field('picture1_url', '{PRODUCTS_IMAGE}', '', false) . '<br>');
     $contents[] = array('text' => ENTRY_GALLERY_OPTION . '<br>' . tep_draw_pull_down_menu('extra_gallery', $galleryOptions, $template['extra_gallery']) . '<br>');
  $contents[] = array('text' => ENTRY_GALLERY_URL . '<br>' . tep_draw_input_field('extra_gallery_url', '{PRODUCTS_IMAGE}', '', false) . '<br>');
  break;

   default:
     $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_GENERATE_LISTINGS . '</b>');
               
     $contents[] = array('text' => '' . TEXT_FROM_TEMPLATE . '<br>' . tep_draw_pull_down_menu('templateid', $templates, ''));
  $contents[] = array('align' => 'left', 'text' => "<br><br><a href=\"#\" onclick=\"return submit_form('GenerateListing');\">Generate Listing</a>");
  break;
  }
     
 

 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
   echo '            <td width="25%" valign="top">' . "\n";

   $box = new box;
   echo $box->infoBox($heading, $contents);

   echo '            </td>' . "\n";
 }
 
?>
 </form>
         </tr>
             <tr>
               <td colspan="7"><table border="0" width="100%" cellpadding="0"cellspacing="2">
                 <tr>
  	 <td class="smallText" valign="top"><?php echo $split->display_count_ex(TEXT_DISPLAY_NUMBER_OF_AUCTIONS); ?></td>
  	 <td class="smallText" align="right"><?php echo $split->display_links_ex(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y', 'oID'))); ?></td>
                 </tr></table>
   </td>
    </tr>
       </table>
 </td>
     </tr>
   </table></td>

<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php
   require(DIR_WS_INCLUDES . 'footer.php');
?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

I hope someone can help me with this, I will also add it to the contributions for the ebay manager so that others may find it usefull.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...