You are here:  » Product Import Must have

Support Forum



Product Import Must have

Submitted by webie on Fri, 2008-08-08 23:50 in

Hi Dave,

Can you guide me in making changes to product import i think the file is admin.php

What I would like is only import products which have a

product description
product price Ie: not 0.00

also is it possible to put a check in place for product description must contain minuim charchator lenght of 50 charactors.

Regards

Darren

Submitted by support on Sat, 2008-08-09 07:46

Hello Darren,

This is best achieved by adding PHP code to check for the conditions you want within the import record handler. If you simply "return" from the record handler the product will not be imported, so you can make the rules as complex as required by writing code to look at the entire record.

To assert the rules described above, look for the following comment in includes/admin.php:

/* apply user filters */

...and change this as follows by adding the assertion code just before the comment:

if (
   (strlen($record[$admin_importFeed["field_description"]]) < 50)
   ||
   ($record[$admin_importFeed["field_price"]] == 0)
   )
   return;
/* apply user filters */

(no description is of course picked up by the rule for a minimum length of 50 characters)

Cheers,
David.

Submitted by webie on Sun, 2008-08-10 18:30

Hi Dave,

Many thanks for the new code work a treat also i checked the databse today and did notice some feeds where not in correct format which left some links dead.

Is it possible to put filter in place to make sure deeplink has http:// if not present then do not import the product.

Regards

Darren

Submitted by support on Mon, 2008-08-11 07:21

Hi Darren,

Sure - just another rule as part of the IF statement:

if (
   (strlen($record[$admin_importFeed["field_description"]]) < 50)
   ||
   ($record[$admin_importFeed["field_price"]] == 0)
   ||
   (substr($record[$admin_importFeed["field_buy_url"]],0,7) <> "http://")
   )
   return;

Cheers,
David.

Submitted by webie on Wed, 2008-08-13 16:37

Hi Dave,

Can we extend that custom check today import new database notice that one merchant had this in description field 'httpwww.drinkstuff.comproductimg28650.jpg' is it possible to put another check in admin to egnor any products that have .jpg .gif , http, www. in the desctiption field & name field.

Regards

Darren

Submitted by support on Thu, 2008-08-14 07:46

Hi Darren,

Sure - that's a little more code than a simple IF statement, so best done in a block of its own immediately after the check code above. Try something like this:

  $stopWords = array(".jpg",".gif","http","www.");
  foreach($stopWords as $stopWord)
  {
    if (strpos($record[$admin_importFeed["field_name"]],$stopWord)!==FALSE) return;
    if (strpos($record[$admin_importFeed["field_description"]],$stopWord)!==FALSE) return;
  }

Cheers,
David.

Submitted by Convergence on Thu, 2012-12-27 06:24

Greetings,

What would the current code be for v12/10B if we wanted to prevent any products from being imported with less than xx amount of characters in the product description?

Thanks!

Submitted by support on Thu, 2012-12-27 10:38

Hi,

I know your version is quite heavily modified so in includes/admin.php look for the comment just before the code that validates the import record prior to importing (314 in the distribution)

  /* check product record for minimum required fields */

...an then add this code:

  if (strlen($importRecord["description"])<250) return;

Simply change the constant 250 to be the minimum number of characters required...

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Thu, 2012-12-27 18:45

Thanks, David!

Will test it out on the next CRON.

Submitted by Convergence on Fri, 2012-12-28 01:17

Worked perfectly!

Thank you yet again, David!

Submitted by TWDesigns on Sun, 2013-01-06 01:19

Does the top most code still apply with v12/10B? I would like to build a set of filters like this as well for entries that are missing pictures along with desc and etc.

Submitted by support on Sun, 2013-01-06 12:08

Hi TWDesigns,

12/10B uses the $importRecord array instead of accessing $record directly; instead of the above look for the following comment at line 312:

  /* check product record for minimum required fields */

...and insert at that point any tests you wish to make e.g.

  if (!$importRecord["image_url"]) return;

The keys to $importRecord are as per the entries in $config_fieldSet in config.advanced.php

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by TWDesigns on Sun, 2013-01-06 15:20

Thank you David!

Submitted by Convergence on Sat, 2013-02-16 05:29

Hi David,

Found a merchant who puts a 0 (zero) in the price field to represent out of stock . Need to be able to drop all records with 0 in the price field. What code do I need to add to make it work with the minimum character mod for our heavily modified 12/10B?

  if (strlen($importRecord["description"])<250) return;

Thanks!

Submitted by support on Sat, 2013-02-16 08:10

Hi,

You need to use PHP's "is very equal to" to test for zero, which is the tripple equals operator. At the same point in the code, have a go with:

  if ($importRecord["price"]==="0") return;

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Sat, 2013-02-16 20:59

Hi David,

Thanks! the Triple equals operator was throwing me - I was trying double and it wasn't working.

However, I had to change it to:

  if ($importRecord["price"]==="0.00") return;

for it to work.

Doesn't seem to be causing a problem.

    /* check product record for minimum required fields */
    if (strlen($importRecord["description"])<10) return;
    if ($importRecord["price"]==="0") return;
    if ($importRecord["price"]==="0.00") return;

Submitted by support on Sun, 2013-02-17 11:17

All looks good!

Zero comparison can be a bit tricky but as long as all working!

Cheers,
David.
--
PriceTapestry.com