cancel
Showing results for 
Search instead for 
Did you mean: 

How to export all product, collection and page urls in all languages ?

How to export all product, collection and page urls in all languages ?

When I export the data only urls for primary store is exported, but I want urls for all stores to be exported.

For example rings page url is:
mysite.com/rings.html  (This is exported)

But there's also spanish store version of it which is:
mysite.com/es/anillos.html (This is not exported. How can I export this as well ?)

2 REPLIES 2

Re: How to export all product, collection and page urls in all languages ?

Hello @seymurcrise57e 

 

You can use the following script to export products with the product URLs:

require './app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$url = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');
$state = $objectManager->get('\Magento\Framework\App\State');
$state->setAreaCode('frontend');
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$storeId = $storeManager->getStore()->getId();
$websiteId = $storeManager->getStore($storeId)->getWebsiteId();
$Mediaurl=$objectManager->get('Magento\Store\Model\StoreManagerInterface')
                    ->getStore()
                    ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection')
                    ->addAttributeToSelect('*');
$dataCollections = $productCollection->load();
$finalData[]=array('SKU','Product Name','Status','Product URL');
foreach($dataCollections as $dataCollection){
    $tmp_data=array();
    $tmp_data[]=$dataCollection['sku'];
	$tmp_data[]=$dataCollection['name'];
    $tmp_data[]=$dataCollection['status'];
    $productUrl = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface')->getById($dataCollection['entity_id'], false, $storeId);
    $tmp_data[]=$productUrl->setStoreId($storeId)->getUrlModel()->getUrlInStore($productUrl, ['_escape' => true]);
    $finalData[]=$tmp_data; 
}
$file_name='catalog_products';
$fileurl=$file_name.'.csv';
createcsv($fileurl,$finalData);
echo 'Done';
function createcsv($fileurl,$csv_data_array){
    $fp = fopen($fileurl, 'w+'); 
    foreach ($csv_data_array as $fields){
    fputcsv($fp,$fields,",");
    }
    fclose($fp);
    return true; 
}

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

 

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9

Re: How to export all product, collection and page urls in all languages ?

To export all product, collection, and page URLs in all languages, you need to bypass the primary store limitation and capture translated URLs. Utilize platform-specific tools like Shopify's Export Translations or Magento's Data Export to generate a CSV with URLs including the language code (e.g., /es/anillos.html).

 

Alternatively, crawl your site with a web scraping tool to comprehensively gather all language versions of product, collection, and page URLs. Remember, the key is to target URLs with language identifiers in their structure.