Command is used to import articles from the old CMS into TRM-CMS. It should be executed with sudo: sudo php artisan articles:sync-old…
We need to provider at least token (which serves as newspaper identifier in the old CMS), Newspaper id (the ID of the newspaper in our DB in trm-cms), start date and end date. Keep in mind that there’s a lot of articles for each newspaper so we need to keep the time interval small (max. 2 months).
Full command signature:
php artisan articles:sync-old {oldNewspaperToken} {newspaperId} {dateFrom} {dateTo}
{--ids=}
{--productMap}
{--onlySyncSecondaryDomains}
{--withSecondaryDomains}
{--onlyCalculationType}
{--categoriesOnly}
{--updateLayoutIdOnly}
{--createdNewProducts}
The API used for getting the article is using token identifiers for each newspaper so we need to provide the token to the newspaper we want to import. This token is available in table newspaper_info in the old system’s database.
The ID of the newspaper for which we’re import articles in our database
Specifies from which date articles should be delivered. Format: {Y-m-d}. Example: 2022-03-01
Specifies up until to which date date articles should be delivered: Format: {Y-m-d}. Example: 2022-04-30
Example command to this moment:
sudo php artisan articles:sync-old 3a9cced82a1a826fa67a3c3d68fc4b50 154 2020-05-01 2020-06-30
Specifies which article IDs you want to import, supports comma separated values. Empty by default.
If you want to import a single article or just a few articles instead of the whole XML result you should use the ids option parameter and pass the desired article ids (from the old system you want to import)
Example command:
sudo php artisan articles:sync-old 3a9cced82a1a826fa67a3c3d68fc4b50 154 2020-05-01 2020-06-30 --ids=1234,6785,9999
Use to map products/domains. If provided then articles will be imported only if their domain is added in the $productMap property inside the code.
First use case: If the newspaper we’re importing have more then one domains in the old system then articles for all domains will be served from the API and if we want to import only articles for one or two domains we need to provide this flag to the command and properly update the $productMap property. For example the CHM Newspapers has 12 domains in the old system. If we want to import articles for only 2 domains (lets say themenwelten.badenertagblatt.ch and themenwelten.bzbasel.ch) then we need to provide those domains in the $productMap property inside the command class:
public $productMap = [
...
'themenwelten.badenertagblatt.ch' => 'themenwelten.badenertagblatt.ch',
'themenwelten.bzbasel.ch' => 'themenwelten.bzbasel.ch',
...
]
The key should be the domain as it is in the old system (without http protocols) and the value should be the domain as it is in the new system (without http protocols).
Second use case is when we want to import articles from domain which have different domain name in the new CMS. Then we need to provide the old domain as it is in the old system as key and the domain to which we want to import as value. For example if we want to import articles from old system domain themenwelten.badenertagblatt.ch into the domain mydomains.test.com in the new system we need to set:
public $productMap = [
...
'themenwelten.badenertagblatt.ch' => 'mydomains.test.com',
...
]
Example command:
sudo php artisan articles:sync-old 3a9cced82a1a826fa67a3c3d68fc4b50 154 2020-09-01 2020-10-31 --productMap
NOTE: If the articles we’re importing are delivered with a domains that does not exist in the system and productMap is not set as an argument then the article will be skipped and not be imported.
By default when importing the articles only the main domain will be assigned to the article, but each article can be assigned to multiple domains. If we provide this option to the script the secondary domains will also be assigned to the article if they exist in the system. This option can be used together with --productMap option to correctly map the secondary domains.
If we already imported some article only with their main domain and we wan’t to run the script again to sync the secondary domains we need to provide this option to the script.
NOTE: If the article does not exist in the system (not already imported) and this option is provided then the article/s will be skipped and will not be imported. If it does exist then only their secondary domains will be inserted and the article itself will not be updated.
Create product with the article’s domains if it does not currently exist. The newspaperId argument will be used as newspaper_id value.
If the article that’s going to be imported does not have it’s domain inserted as a product it will be skipped from importing unless this argument is passed to the command.
This argument is used in rare occasions.
If we already imported some article and we want to update their calculation type provide this argument. NOTE: If the article does not exist in the system (not already imported) and this option is provided then the article/s will be skipped and will not be imported. If it does exist then only their calculation type will be updated and the article itself will not be updated.
If we already imported some article and we want to update their categories provide this argument. NOTE: If the article does not exist in the system (not already imported) and this option is provided then the article/s will be skipped and will not be imported. If it does exist then only their categories will be updated and the article itself will not be updated.
Simmilary to the other *Only arguments this one will only update the article layout for already imported articles.