Zen Cart Logo
Forums / All Other Contributions/Addons / proposed easy populate mods

proposed easy populate mods

Locked

Views: 1,309

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
4 Jun 2009, 11:04 PM
#1
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

proposed easy populate mods

I have been asking for help in making a mod to Easy Populate so
that I can include v_product_is_call to the product upload file.

Here are the mods to Admin/easypopulate.php that I think MIGHT
accomplish what I want to do. Could someone knowledgeable with
Easy Populate please review the proposed changes and tell me
whether the proposed changes are correct and sufficient to do
what I want. I really appreciate the support.

Here are the changes: Line numbers shown are the beginning of
section of code that is modified.

1276 // langer - input: $readed
// johnboycr - added v_product_is_call to the array
// these are the fields that will be defaulted to the current values in the database if they are not found in the incoming file
// langer - why not qry products table and use result array??
$default_these = array(
'v_products_image',
// redundant image mods removed
'v_categories_id',
'v_products_price',
'v_products_quantity',
'v_products_weight',
'v_date_added',
'v_date_avail',
'v_instock',
'v_tax_class_title',
'v_manufacturers_name',
'v_manufacturers_id',
'v_products_dim_type',
'v_products_length',
'v_products_width',
'v_product_is_call',
'v_products_height'
);

1430 $sql = "SELECT
p.products_id as v_products_id,
p.products_model as v_products_model,
p.products_image as v_products_image,
p.products_price as v_products_price,
p.products_weight as v_products_weight,
p.products_date_added as v_date_added,
p.products_date_available as v_date_avail,
p.products_tax_class_id as v_tax_class_id,
p.products_quantity as v_products_quantity,
p.product_is_call as v_product_is_call,
p.manufacturers_id as v_manufacturers_id,
subc.categories_id as v_categories_id
FROM
".TABLE_PRODUCTS." as p,
".TABLE_CATEGORIES." as subc,
".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
WHERE
p.products_id = ptoc.products_id AND
p.products_model = '" . zen_db_input($items[$filelayout['v_products_model']]) . "' AND
ptoc.categories_id = subc.categories_id
";

	$result = ep_query($sql);
	$row =  mysql_fetch_array($result);
	$product_is_new = true;

1727 // johnboycr - if null, make product_is_call = 0
if (trim($v_product_is_call) == '') {
$v_product_is_call = 0;
}

4 Jun 2009, 11:16 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,646
Plugin Contributions:
0

Re: proposed easy populate mods

Moderator's note: thread moved from General questions to Contributed Add Ons.

4 Jun 2009, 11:35 PM
#3
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

I probably should have submitted this to Software Contributions,
but was waiting to see if the proposed changes would work before
submittal. Thanks for moving it here Kim.

Now if I can get a good answer to my question ....

5 Jun 2009, 2:35 PM
#4
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: proposed easy populate mods

I only know v1.2.5.4 so can only comment on that but I think that it's the same with 1.2.5.5. I wrote a tutorial in the forum about adding fields here, there are 6 places in the file that you need to add your new fields.

As far as seeing if your changes works, set up a test site with the demo products, install EP with your modifications, download a complete file, open that file and see if your added fields are there. Make some changes to the fields in question, upload the file through EP, go to the product to see if your changes worked.

If the changes worked then you know that you are good.

This line is not necessary:

1727        // johnboycr - if null, make product_is_call = 0
        if (trim($v_product_is_call) == '') {
            $v_product_is_call = 0;
        }     
```Since if you don't enable the field by making the value 1 it will be skipped automatically anyway. Just add v_product_is_call in the 6 places mentioned in the tutorial, the field on the spreadsheet file will accept a 0 for off/false or 1 for on/true. There is no need to add any conditionals to the EP file for this.

It doesn't sound like adding a couple of fields is worth making a whole new version of EP for the downloads section unless you have changed the functionality somehow which it seems like you haven't.

Let me know how it goes.
5 Jun 2009, 7:24 PM
#5
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

Thanks to lankeeyankee for putting me on the right track.
However, there were a couple more changes that I had to make to get it to work correctly.

Perhaps I should post the new code for all to see. Not sure how to do that but I will look in to it.

5 Jun 2009, 7:37 PM
#6
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: proposed easy populate mods

JohnBoyCR:

Thanks to lankeeyankee for putting me on the right track.
However, there were a couple more changes that I had to make to get it to work correctly.

Perhaps I should post the new code for all to see. Not sure how to do that but I will look in to it.

Please do post the code so we can see what other changes you had to make, along with the version of EP and zencart that you are using.

To post the code use the PHP tags that are above the text input box that you write the post in. It's the second from the right on the second row.

5 Jun 2009, 8:21 PM
#7
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

Here is the code for my mod. The file is quite large so I have shown only those areas affected. Please view with a PHP editor such as Notepad ++. The code changes follow here:

around line 384

	$header_array = array(
			'v_specials_price'    => $iii++,
			'v_specials_date_avail'     => $iii++,
			'v_specials_expires_date'     => $iii++,
			'v_products_price'    => $iii++,
			'v_products_weight'   => $iii++,
			'v_product_is_call'   => $iii++,
			'v_date_avail'      => $iii++,
			'v_date_added'      => $iii++,
			'v_products_quantity'   => $iii++,
			);

around line 452

    $filelayout_sql = "SELECT
			p.products_id as v_products_id,
			p.products_model as v_products_model,
			p.products_image as v_products_image,
			p.products_price as v_products_price,
			p.products_weight as v_products_weight,
			p.product_is_call as v_product_is_call,
			p.products_date_available as v_date_avail,
			p.products_date_added as v_date_added,
			p.products_tax_class_id as v_tax_class_id,
			p.products_quantity as v_products_quantity,
			p.manufacturers_id as v_manufacturers_id,
			subc.categories_id as v_categories_id,
			p.products_status as v_status
			FROM
			".TABLE_PRODUCTS." as p,
			".TABLE_CATEGORIES." as subc,
			".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
			WHERE
			p.products_id = ptoc.products_id AND
			ptoc.categories_id = subc.categories_id
			";

around line 596

     $filelayout_sql = "SELECT
			p.products_id as v_products_id,
			p.products_model as v_products_model,
			p.products_image as v_products_image,
			p.products_price as v_products_price,
			p.products_weight as v_products_weight,
			p.product_is_call as v_product_is_call,
			p.products_date_added as v_date_added,
			p.products_date_available as v_date_avail,
			p.products_tax_class_id as v_tax_class_id,
			p.products_quantity as v_products_quantity,
			p.manufacturers_id as v_manufacturers_id,
			subc.categories_id as v_categories_id
			FROM
			".TABLE_PRODUCTS." as p,
			".TABLE_CATEGORIES." as subc,
			".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
			WHERE
			p.products_id = ptoc.products_id AND
			ptoc.categories_id = subc.categories_id AND
			p.products_status = '1'
			";

around line 1284

    $default_these = array(
		'v_products_image',
		// redundant image mods removed
		'v_categories_id',
		'v_products_price',
		'v_products_quantity',
		'v_products_weight',
		'v_product_is_call',
		'v_date_added',
		'v_date_avail',
		'v_instock',
		'v_tax_class_title',
		'v_manufacturers_name',
		'v_manufacturers_id',
		'v_products_dim_type',
		'v_products_length',
		'v_products_width',
		'v_product_is_call',
		'v_products_height'
	);

around line 1435

  		$sql = "SELECT
			p.products_id as v_products_id,
			p.products_model as v_products_model,
			p.products_image as v_products_image,
			p.products_price as v_products_price,
			p.products_weight as v_products_weight,
			p.product_is_call as v_product_is_call,
			p.products_date_added as v_date_added,
			p.products_date_available as v_date_avail,
			p.products_tax_class_id as v_tax_class_id,
			p.products_quantity as v_products_quantity,
			p.manufacturers_id as v_manufacturers_id,
			subc.categories_id as v_categories_id
			FROM
			".TABLE_PRODUCTS." as p,
			".TABLE_CATEGORIES." as subc,
			".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
			WHERE
			p.products_id = ptoc.products_id AND
			p.products_model = '" . zen_db_input($items[$filelayout['v_products_model']]) . "' AND
			ptoc.categories_id = subc.categories_id
			";

around line 1911

  $query = "INSERT INTO ".TABLE_PRODUCTS." (
						products_image,
						products_model,
						products_price,
						products_status,
						products_last_modified,
						products_date_added,
						products_date_available,
						products_tax_class_id,
						products_weight,
						product_is_call,
						products_quantity,
						manufacturers_id)
							VALUES (
								'".zen_db_input($v_products_image)."',";
				// redundant image mods removed
				$query .="'".zen_db_input($v_products_model)."',
									'".zen_db_input($v_products_price)."',
									'".zen_db_input($v_db_status)."',
									CURRENT_TIMESTAMP,
									$v_date_added,
									$v_date_avail,
									'".zen_db_input($v_tax_class_id)."',
									'".zen_db_input($v_products_weight)."',
									'".zen_db_input($v_product_is_call)."',
									'".zen_db_input($v_products_quantity)."',
									'$v_manufacturer_id')
								";

around line 1969

    $query .= '", products_weight="'.zen_db_input($v_products_weight) .
						'", product_is_call="'.zen_db_input($v_product_is_call) .
						'", products_tax_class_id="'.zen_db_input($v_tax_class_id) . 
						'", products_date_available= ' . $v_date_avail .
						', products_date_added= ' . $v_date_added .
						', products_last_modified=CURRENT_TIMESTAMP' .
						', products_quantity="' . zen_db_input($v_products_quantity) .  
						'" ,manufacturers_id=' . $v_manufacturer_id . 
						' , products_status=' . zen_db_input($v_db_status) . '
						WHERE
							(products_id = "'. $v_products_id . '")';
5 Jun 2009, 8:36 PM
#8
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

For those interested, I am attaching a zipped file of the
easypopulate.php file. This file would replace the file in your
Admin directory. Be sure to make a backup of your existing
file before uploading this new version.

This mod has been tested in several ways. I have uploaded new
product with the v_product_is_call set to 0 and set to 1.
I have uploaded an existing product, changing the v_product from
one state to another.

All seems to work well.

Before installing and using this code, be sure to make a full
backup of your database. JUST IN CASE !

Once you have installed this new version of easypopulate.php
you will want to first download a full ep of your database so that
you have the proper template.

Feel free to give feedback on this mod.

5 Jun 2009, 8:53 PM
#9
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

An anomaly has been detected by the author of this mod. I repeated the insertion of v_product_is_call in one of the arrays. This does not affect the function, but was deleted in the zip file that I uploaded. OOPS!

5 Jun 2009, 11:16 PM
#10
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

Found another anomaly. While the previous zip file will work
correctly, it still has a duplicate entry for product_is_call in one
of the arrays. To ensure that the user has CLEAN code, please use the attached version. This one should be clean. It was
downloaded from my Zen site so I know it works. Sorry for any
confusion.

6 Jun 2009, 12:08 AM
#11
johnboycr avatar

johnboycr

Zen Follower

Join Date:
Jan 2009
Posts:
201
Plugin Contributions:
2

Re: proposed easy populate mods

A bit more information about this mod. This is using Zen Cart
version 1.3.8 and Easy Populate version 1.2.5.4.