I'm looking to retrieve all URLs of a Magento website (CMS pages, categories, products...) subdivided by store view. Something like the default Magento Sitemap, but with a different format: specifically I'm trying to get a "one URL per row" plain text file, one for each store view.

2 Answers 2


Take a look at how Magento generates it's sitemap.xml file.

Specifically the Mage_Sitemap_Model_Sitemap class method generateXml. For example, following snippet generates them for the categories, I've rewritten it a little to export to a flat text file.

$ioWrite = new Varien_Io_File();
$path = ''; 
$ioWrite->open(array('path' => $path));

$storeId =  Mage::app()->getStore()->getId();
$date    = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
$baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

 * Generate categories sitemap
$changefreq = (string)Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
$priority   = (string)Mage::getStoreConfig('sitemap/category/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId);
$categories = new Varien_Object();
Mage::dispatchEvent('sitemap_categories_generating_before', array(
    'collection' => $categories
foreach ($categories->getItems() as $item) {
    $ioWrite->streamWrite(htmlspecialchars($baseUrl . $item->getUrl()));

Add the code from the class to your own script to generate a text file

  • Thanks @Sander for the hints, I've got a solution starting from this.
    – Riccardo
    Nov 11, 2015 at 13:03

Thanks to @sander-mangel I've developed a solution for my specific case: https://gist.github.com/RiccardoB/2117046a97719b413c8a

If you have any optimization/fix to suggest, feel free to comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.