Zen Cart Logo
Forums / Customization from the Admin / Adding Manufacturer sort order

Adding Manufacturer sort order

Views: 1,367

Results 1 to 4 of 4
26 Jan 2013, 2:25 PM
#1
edialedarb avatar

edialedarb

New Zenner

Join Date:
Aug 2008
Posts:
6
Plugin Contributions:
0

Adding Manufacturer sort order

My client wants to be able to set the order in which the manufacturers are displayed. So I would like to put a sort order in the admin area where you name the manufacturer.

Is this easy and can someone help me out?

Thanks

26 Jan 2013, 3:53 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Adding Manufacturer sort order

It's probably fairly easy for someone fluent in PHP, but not for the rest of us. I have a site that could use this functionality too, and have fiddled with the code trying to make it happen, but no luck. You'll (we'll) probably need paid help.

28 Jan 2013, 1:23 AM
#3
edialedarb avatar

edialedarb

New Zenner

Join Date:
Aug 2008
Posts:
6
Plugin Contributions:
0

Re: Adding Manufacturer sort order

Hi Stevesh and anyone else reading this thread who needs this option.

After a little bit of code crawling I found out how to do this. First off I will say that I am not a php master, just have a reasonable understanding of basic php and coding, so there may be a better way to do this. Please feel free to join in if you can improve this.

The usual disclaimer applies about backing up your database and file before making the changes so you can go back if it doesn't work of breaks something.

BTW I am using version 1.5.1, the line numbers below may be different to yours but they should be close.

  1. First I went in through phpMyAdmin and added a field to the manufacturers table called manufacturers_sort_order with a type of INT(11), default 0, NOT NULL
  2. Then I opened the file admin/manufacturers.php and made the following edits
    Line 20, just after
$manufacturers_name = zen_db_prepare_input($_POST['manufacturers_name'])

Add

$manufacturers_sort_order = zen_db_prepare_input($_POST['manufacturers_sort_order']);

Line 22, change

$sql_data_array = array('manufacturers_name' => $manufacturers_name);

to

$sql_data_array = array('manufacturers_name' => $manufacturers_name, 'manufacturers_sort_order' => $manufacturers_sort_order);

Line 255, just after

$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', '', zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));

Add

$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_SORT_ORDER . '<br>' . zen_draw_input_field('manufacturers_sort_order', '', 'size="3"'));

You could add this elsewhere in the form, but I wanted my field to appear under the name when adding or editing the manufacturer.

Line 287, just after

$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', htmlspecialchars($mInfo->manufacturers_name, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));

Add

$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_SORT_ORDER . '<br>' . zen_draw_input_field('manufacturers_sort_order', $mInfo->manufacturers_sort_order, 'size="3"'));

That worked for me, and I suppose you can adapt this to add whatever fields you want.

I hope this helps someone else out there now, or in the future.

28 Jan 2013, 1:35 AM
#4
edialedarb avatar

edialedarb

New Zenner

Join Date:
Aug 2008
Posts:
6
Plugin Contributions:
0

Re: Adding Manufacturer sort order

Sorry, one more thing.

Edit the language file admin/includes/languages/english/manufacturers.php and add the definition

define('TEXT_MANUFACTURERS_SORT_ORDER', 'Manufacturers Sort Order:');

Cheers