I am using an older version of Cross Sell, and I'm not sure which version, but I wanted to post this because it's such an improvement.
The Edit page becomes very unmanageable when you have lots of items in your store. This modification makes it so that the products are 5 columns across, rather than 1. This modification also will allow you to click the product image to select for Cross Sell, rather than just the checkbox.
TO INSTALL:
1. BACK UP! I have no idea which version of the Addon I'm using.
2. Near Line 181, find the code starting with
// This bit does the 'EDIT' page (previously Add/Remove)
and ending with
//////////////////////////////////////////////////////////////////////////////////
// This bit does the 'PRIORITISE' page (previously Sort)
3. Replace with the following:
//////////////////////////////////////////////////////////////////////////////////
// This bit does the 'EDIT' page (previously Add/Remove)
if ($_POST && !$sort)
{
if ($_POST[run_update]==true)
{
$query ="DELETE FROM " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".$_POST[add_related_product_ID]."'";
if (!tep_db_query($query))
exit('could not delete');
}
if ($_POST[xsell_id])
foreach ($_POST[xsell_id] as $temp)
{
$query = "INSERT INTO " . TABLE_PRODUCTS_XSELL . " VALUES ('',$_POST[add_related_product_ID],$temp,1)";
if (!tep_db_query($query))
exit('could not insert to DB');
}
echo '<a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, '', 'NONSSL') . '">Click Here to add a new cross sale</a><br>' . "n";
if ($_POST[xsell_id])
echo '<a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, 'sort=1&add_related_product_ID=' . $_POST[add_related_product_ID], 'NONSSL') . '">Click here to sort (top to bottom) the added cross sale</a>' . "n";
}
if ($add_related_product_ID && ! $_POST && !$sort)
{ ?>
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#999999">
<form action="<?php tep_href_link(FILENAME_XSELL_PRODUCTS, '', 'NONSSL'); ?>" method="post">
<?php
$query = "select b.language_id, a.products_id, b.products_name, b.products_description, " .
"a.products_quantity, a.products_model, a.products_image, a.products_status, " .
"b.products_url, a.products_price from products a, products_description b where b.products_id = a.products_id and b.language_id = 2 and a.products_id = '".$add_related_product_ID."' AND a.products_status = 1";
list ($language_id, $PRODUCTS_id, $PRODUCTS_name, $PRODUCTS_description , $PRODUCTS_quantity , $PRODUCTS_model , $PRODUCTS_image , $PRODUCTS_url , $PRODUCTS_price, $PRODUCTS_status ) = general_db_conct($query);
echo '<span class="pageHeading">Setting cross-sells for: ' . $PRODUCTS_model[0] . ' (Product ID: ' . $PRODUCTS_id[0] . ') <br><br>' . tep_info_image($PRODUCTS_image[0], $PRODUCTS_name[0], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</span><br><br>';
?>
<?
//changed order by a.products_id to a.products_model below
$query = "select b.language_id, a.products_id, b.products_name, b.products_description, " .
"a.products_quantity, a.products_model, a.products_image, " .
"b.products_url, a.products_status, a.products_price from products a, products_description b where b.products_id = a.products_id and b.language_id = 2 and a.products_id != '" . $add_related_product_ID . "' and a.products_status = 1 ORDER BY a.products_model";
list ($language_id, $PRODUCTS_id, $PRODUCTS_name, $PRODUCTS_description , $PRODUCTS_quantity , $PRODUCTS_model , $PRODUCTS_image , $PRODUCTS_url , $PRODUCTS_status, $PRODUCTS_price ) = general_db_conct($query);
$num_of_products = sizeof($PRODUCTS_id);
$query = "select * from " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '" . $add_related_product_ID . "'";
list ($ID_PR, $PRODUCTS_id_PR, $xsell_id_PR) = general_db_conct($query);
$num_of_products = sizeof($PRODUCTS_id);
echo '<p>There are '.$num_of_products.' available cross-sell products</p>';
$a = 0;
for ($i=0; $i < $num_of_products; $i++)
{
if($a == 0) { echo ' <tr bgcolor="#DFE4F4">'; }
echo "<td class="dataTableContent" align='center' style='padding:5px;'>"
. '<label onMouseOver="this.style.cursor='pointer'; this.style.cursor='hand'">'
. tep_info_image($PRODUCTS_image[$i], $PRODUCTS_name[$i], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)
. '<br />'. '<strong>ID:</strong> '.$PRODUCTS_id[$i]
. '<br />'. '<strong>Model #:</strong> '. $PRODUCTS_model[$i]
. '<br />'. '<strong>Price:</strong> ' . $currencies->display_price($PRODUCTS_price[$i], tep_get_tax_rate($product_info_values['products_tax_class_id'])); ?>
<br /><input onMouseOver="this.style.cursor='pointer'; this.style.cursor='hand'"
<?php /* See if item is in the DB. Display and set checkbox. */
// Adam@CP: Changed order of columns.
$run_update = false; // Set False to insert new entry in the DB
if ($xsell_id_PR)
foreach ($xsell_id_PR as $compare_checked)
if ($PRODUCTS_id[$i] === $compare_checked) {
echo "checked ";
$run_update = true;
}
?>
size="20" name="xsell_id[]" type="checkbox" value="<?php echo $PRODUCTS_id[$i]; ?>">
Cross-sell</label>
<? echo "</td>n";
$a++;
if($a == 5) { echo '</tr>'; $a = 0;}
} // end for num_of_products
?>
<tr>
<td colspan="4">
<input type="hidden" name="run_update" value="<?php if ($run_update==true) echo "true"; else echo "false" ?>">
<input type="hidden" name="add_related_product_ID" value="<?php echo $add_related_product_ID; ?>">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</form>
</table>
<? }
// sort routines
if ($sort==1)
{
// first lets take care of the DB update.
$run_once=0;
if ($_POST)
foreach ($_POST as $key_a => $value_a)
{
tep_db_connect();
$query = "UPDATE " . TABLE_PRODUCTS_XSELL . " SET sort_order = '" . $value_a . "' WHERE xsell_id= '$key_a' ";
if ($value_a != 'Update')
if (!tep_db_query($query))
exit('Could not UPDATE DB');
else if ($run_once==0)
{
echo '<b class='main'>Cross-sells updated <a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, '', 'NONSSL') . '">Back to cross-sell admin</a></b><br>' . "n";
$run_once++;
}
}// end of foreach.