Skip to content

Instantly share code, notes, and snippets.

@hissy hissy/
Last active Dec 19, 2018

What would you like to do?
[concrete5] [v8] Bulk mapping pages between multilingual sitemaps from command line

What this script does?

  1. Get all pages in original multilingual section
  2. Get a page in destination multilingual section that has same collection path
  3. Make a relation
  4. Go to next page

How to use

concrete/bin/concrete5 c5:exec bulk_mapping_multilingual_sitemap.php
use Concrete\Core\Page\Page;
use Concrete\Core\Multilingual\Page\Section\Section;
use Concrete\Core\Multilingual\Page\PageList as MultilingualPageList;
$originSection = Section::getByLocale('ja_JP');
$destSection = Section::getByLocale('en_US');
$pl = new MultilingualPageList();
$results = $pl->getResults();
$mapped = 0;
$skipped = 0;
foreach ($results as $result) {
$path = $result->getCollectionPath();
$destPage = Page::getByPath($destSection->getCollectionPath() . $path, 'RECENT', $destSection->getSiteTreeObject());
if (is_object($destPage) && !$destPage->isError()) {
if (!Section::isAssigned($result)) {
Section::relatePage($result, $destPage, $destSection->getLocale());
} else {
echo sprintf('%d pages mapped. %d pages skipped.', $mapped, $skipped);
echo "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.