You are here:  » Drop products filter feature

Support Forum



Drop products filter feature

Submitted by mikecdprice on Fri, 2011-01-21 13:50 in

Is it possible to have a mod that if I ask the script to drop products if mask is not listed in all fields not just single ones.

I was not sure if by adding filter rule it would check each then drop at the end of the process.

I'm working with a large CSV and want to create a niche store.

Please advise.

Thank you.

Submitted by support on Fri, 2011-01-21 14:10

Hi Mike,

Multi-field record dropping is probably best implemented as a simple modification within the import record handler function in includes/admin.php. In that file, look for the following comment (line 273 in the 12/10A distribution):

    /* check product record for minimum required fields */

To drop the record if the word "mask" is not present in the name or description, REPLACE the above code with the following:

    $keyword = "mask";
    if (
       (strpos($importRecord["name"],$keyword)===FALSE)
       &&
       (strpos($importRecord["description"],$keyword)===FALSE)
       )
     {
       return;
     }
    /* check product record for minimum required fields */

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Fri, 2011-01-21 15:13

Hello,

Thank you for your response. Is it possible to have more than one keyword?

Like

$keyword = "mask, fangs, wig";

;)

Thank you.

Submitted by support on Fri, 2011-01-21 15:37

Hi Mike,

No probs - have a go with this as the replacement:

    $dropRecord = TRUE;
    $keywords = array("mask","fangs","wig");
    foreach($keywords as $keyword)
    {
      if (
         (strpos($importRecord["name"],$keyword)!==FALSE)
         ||
         (strpos($importRecord["description"],$keyword)!==FALSE)
         )
         {
           $dropRecord = FALSE;
           break;
         }
    }
    if ($dropRecord) return;
    /* check product record for minimum required fields */

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Fri, 2011-01-21 15:48

Thank you for your help.

Submitted by mikecdprice on Thu, 2011-02-17 17:03

Hello David,

How do I add the keyword and have the script avoid just looking for punctuation. I was testig like Mask would only bring up exact Mask and if I added mask also it added 430 more products that had the mask keyword. How would I do that. I was trying to make a site that way and it very tedius to add keywords twice one lower case and one with upper case. Is there a way to add one to just look at the keyword itself?

Thank you,
Michael

Submitted by support on Thu, 2011-02-17 17:06

Hi Mike,

Very easy to make case insensitive... in place of:

      if (
         (strpos($importRecord["name"],$keyword)!==FALSE)
         ||
         (strpos($importRecord["description"],$keyword)!==FALSE)
         )

...use:

      if (
         (strpos(strtolower($importRecord["name"]),strtolower($keyword))!==FALSE)
         ||
         (strpos(strtolower($importRecord["description"]),strtolower($keyword))!==FALSE)
         )

Cheers,
David.
--
PriceTapestry.com

Submitted by mikecdprice on Thu, 2011-02-17 21:14

Wonderful! Thank you for your help.