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
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
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.
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
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.
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!
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
Thanks, David!
Will test it out on the next CRON.
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.
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
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!
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
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;
All looks good!
Zero comparison can be a bit tricky but as long as all working!
Cheers,
David.
--
PriceTapestry.com
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.