You are here:  » Edit Register / Feeds


Edit Register / Feeds

Submitted by gregor on Thu, 2012-06-14 13:11 in

Hi David, I've always been curious as to the reasons why the Register link does not bring up the information from the Feeds file when you open it. If you want to update a feed's registration information, you have to start from scratch and completely redefine it. This is inconvenient and can be dangerous if you get something wrong. I assume there must be a good reason for this, but how hard would it be to pre-populate the fields with data from the Feeds table when the page opens? Would you please give me some hints on how to do this, and maybe some insight into the potential pitfalls?

Thanks,
Gregor

Submitted by support on Thu, 2012-06-14 14:04

Hi Gregor,

Sure, Feed Registration Step 2 can be pre-populated if a feed is already registered. To do this, edit admin/feeds_register_step2.php and look for the following code at line 91 (13/03A) / line 229 (14/06A) / line 246 (15/09A / 16/10A)

  require("admin_header.php");

...and REPLACE with:

  if (!isset($_POST["submit"]))
  {
    $sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` WHERE filename='".database_safe($filename)."'";
    if (database_querySelect($sql,$feeds))
    {
      $feed = $feeds[0];
      $_POST["merchant"] = $feed["merchant"];
      $_POST["field_merchant"] = $feed["field_merchant"];
      $_POST["category"] = $feed["user_category"];
      $_POST["brand"] = $feed["user_brand"];
      foreach($config_fieldSet as $field => $caption)
      {
        $_POST["field_".$field] = $feed["field_".$field];
      }
    }
  }
  require("admin_header.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by gregor on Thu, 2012-06-14 14:59

That's great David, thank you. Will be a big help! Would it also be possible to default step1 also? Sometimes the auto-detected feed format needs to be overridden and that's one of the hardest things for me to keep straight.

Thanks,
Greg

Submitted by support on Thu, 2012-06-14 15:14

Hi Greg,

Sure - in admin/feeds_register_step1.php look for the following code at line 20 (14/06A) / line 23 (15/09A / 16/10A)

  $formatDetected = MagicParser_getFormat($config_feedDirectory.$filename);

...and REPLACE with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` WHERE filename='".database_safe($filename)."'";
  if (database_querySelect($sql,$feeds))
  {
    $feed = $feeds[0];
    $formatDetected = $feed["format"];
  }
  else
  {
    $formatDetected = MagicParser_getFormat($config_feedDirectory.$filename);
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by gregor on Thu, 2012-06-14 19:20

Works a treat ... Thank you so much! This will make life so much easier.

Gregor

Submitted by ChrisNBC on Thu, 2017-11-09 12:29

Hi David,

The above mods do not appear to have any effect on v 16_10A. I have used them both fine in previous versions and wondered if you could confirm if the mod works for the latest version.

Thanks in advance.

Best regards
Chris

Submitted by support on Thu, 2017-11-09 13:11

Hi Chris,

I've just double checked and both modifications (step 1 and 2) worked fine against 16/10A - were you having problems with both or just one of the mods?

Cheers,
David.
--
PriceTapestry.com

Submitted by sydney880 on Thu, 2017-11-09 14:28

I haven't applied this mod yet, but am sure its great. I have also always wondered why when changing a feed, you have to start from scratch and register it again and lose the previous links.

Submitted by support on Thu, 2017-11-09 14:45

Thanks Sydney, i'll consider including this in the next distribution...

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Fri, 2017-11-10 19:01

Hi David,

Thanks for your quick reply. Sorry for the delay in getting back to you, I wanted to double check the code again before responding. I think the issue was caused by one of my changes which is now resolved and the above works perfectly.

Have a great weekend.

Best regards

Chris

Submitted by sydney880 on Mon, 2017-11-20 15:54

Hi,

I just got around to implementing it. It is better than before. But I believe the code is designed to map the fields in the field mapping already exists. But for some feeds, I have left the image mapping blank (because feeds has some images that don't work) and for some feeds, I have left the category mapping blank (because I don't want to have the products appear by category). Is there any way to have the mapping left blank if the last registration of the feed was blank?

Thanks

Submitted by support on Tue, 2017-11-21 10:26

Hi Sydney,

Ah yes - if a field was not previously mapped the auto-detection logic would still try to map the field, so to prevent this, edit admin/feeds_register_step2.php and look for the following code at line 218:

    if (!$default)

...and REPLACE with:

    if (!$default && !isset($_POST["field_".$name]))

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Mon, 2022-11-21 09:48

Hi.

I think there is a minor bug in this reply.

If I am not wrong, it must be:

      $_POST["category"] = $feed["user_category"];
      $_POST["brand"] = $feed["user_brand"];

Submitted by support on Tue, 2022-11-22 10:06

Thanks! Corrected above...

Cheers,
David.
--
PriceTapestry.com