Permalinks - Update tables using cron

By gversion - October 3, 2020

Hello,

I have set up a crawler to import product listings from various websites on a daily basis. I would like to have CMSB auto generate the permalinks for the products. Is it possible to somehow get the Permalinks plugin to run via cron so my product listings table has any missing permalinks generated every hour?

Or is there a better way to do this?

Thanks for any help or advice!

Regards,
Greg

By gversion - October 6, 2020

Hi,

Further to my previous post, we have modified the crawler to create the permalink so don't need to run the permalink plugin anymore.

So now the products are being imported with a permalink value however when I view the product page at the front end I receive a 404 error.

To resolve this I just need to go into CMSB, edit the product and simply click "save" (without making any changes to any of the fields) and then the product loads correctly at the front end (no more 404!).

I have compared the product row in the database before and after saving the listing and the fields are identical so I don't know why the product suddenly loads after saving the record in CMSB.

I would be extremely grateful if someone could explain to me what's going on here.

Thank you,

Greg

By Toledoh - October 6, 2020

Hi Greg.

No idea if this will help, but in the plugin screen, there's a link to "Update table" which runs /cmsb/admin.php?_pluginAction=permalink_pluginMenu_updateTable

Could you use that somehow?

Cheers,
Tim (toledoh.com.au)

By gversion - October 6, 2020

Hi Tim,

Thanks very much for the suggestion. I tried to run this but it didn't fix the issue...

Regards,

Greg

By gversion - October 6, 2020

Problem identified! We need the crawler to update the permalinks table too. Manually running the permalinks plugin doesn't do this (I guess because the crawler has already created the permalinks).

Maybe we should just have the permalinks plugin run via cron every 5 minutes and not have the crawler create the permalinks...

Is it possible to configure the permalinks plugin to update a specific table on cron?

Thanks again,

Greg

By gversion - October 9, 2020

Hi,

If anyone could get back to me on this question it would be hugely appreciated:

Is it possible to configure the permalinks plugin to update a specific table on cron?

Thank you,

Greg

By Carl - October 9, 2020

Hi Greg,
I'm looking into whether or not this is possible or how it can be done. I will post an answer here when I find out more.

Carl

PHP Programmer

interactivetools.com

By Carl - October 9, 2020

The constant is defined in init.php, so this should fix those errors/warnings.

<?php
require_once 'cmsb/lib/init.php';
require_once 'cmsb/lib/schema_functions.php';
require_once 'cmsb/lib/mysql_functions.php';
require_once 'cmsb/lib/database_functions.php';
require_once 'cmsb/plugins/permalinks/permalinks_pluginsMenu.php';

$response = _permalink_updateTable('listings');
Carl

PHP Programmer

interactivetools.com

By gversion - October 9, 2020

Hi Carl,

That's fantastic, thank you very much!

Regards,

Greg