You are here:  » Filter to import only X records from a datafeed


Filter to import only X records from a datafeed

Submitted by CashNexus on Thu, 2020-01-09 21:14 in

Hello David,

Let me ask you - is it possible to add a filter to import only X records (no matter how much records in a datafeed) ?
For example, I'd like to import only 10 000 records.
There is a "trial" restriction - but it's the PHP code, not a filter what can be set for some specific datafeeds.

Wish you the prosperous New 2020 Year !
Best regards
Serge

Submitted by support on Fri, 2020-01-10 09:52

Hi Serge,

Happy New Year to you too.

There's an import limit filter described in this comment...

Cheers,
David.
--
PriceTapestry.com

Submitted by CashNexus on Sat, 2020-01-18 23:21

Hello David,
a small issue found - this importLimit Filter overrides Trial Import settings what PT interface makes by
http://example.com/admin/feeds_import.php?limit=10&filename=Example01.xml
because if importLimit Filter set to 1000 records - it anyway imports 1000 records, not ?limit=10 if we try Trial Import.
Could this issue be solved somehow ?
Thank you as always,
Best regards,
Serge

Submitted by support on Mon, 2020-01-20 10:52

Hello Serge,

Without any complex changes to the import process if you simply replace the filter as follows it won't apply the limit if currently set to 10 (Trial Import)...

  /*************************************************/
  /* importLimit */
  /*************************************************/
  $filter_names["importLimit"] = "Import Limit";
  function filter_importLimitConfigure($filter_data)
  {
    print "Max Products:<br />";
    print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    widget_errorGet("text");
  }
  function filter_importLimitValidate($filter_data)
  {
    if (!$filter_data["text"])
    {
      widget_errorSet("text","required field");
    }
  }
  function filter_importLimitExec($filter_data,$text)
  {
    global $admin_importLimit;
    if ($admin_importLimit != 10)
    {
      $admin_importLimit = intval($filter_data["text"]);
    }
    return $text;
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by CashNexus on Mon, 2020-01-20 17:03

Yes, thank you David ! This solution solves the issue.
Best regards,