|  |  | @@ -0,0 +1,83 @@ | 
    
    |  |  | <?php | 
    
    |  |  | require_once 'app/Mage.php'; | 
    
    |  |  | umask(0); | 
    
    |  |  | 
 | 
    
    |  |  | // set store view | 
    
    |  |  | $store_view_filter = isset($_REQUEST['store_view']) ? $_REQUEST['store_view'] : false; | 
    
    |  |  | 
 | 
    
    |  |  | // set export type | 
    
    |  |  | $export_to = isset($_REQUEST['export_to']) ? $_REQUEST['export_to'] : false; | 
    
    |  |  | 
 | 
    
    |  |  | // return values | 
    
    |  |  | $urls = array(); | 
    
    |  |  | 
 | 
    
    |  |  | // get stores data | 
    
    |  |  | $store_views = Mage::app()->getStores(); | 
    
    |  |  | foreach ($store_views as $store_view) | 
    
    |  |  | { | 
    
    |  |  | // skip not requested stores | 
    
    |  |  | if($store_view_filter && $store_view_filter !== $store_view->getCode()) continue; | 
    
    |  |  | 
 | 
    
    |  |  | $storeId = $store_view->getStoreId(); | 
    
    |  |  | $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); | 
    
    |  |  | 
 | 
    
    |  |  | // get categories | 
    
    |  |  | $collection = Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId); | 
    
    |  |  | $categories = new Varien_Object(); | 
    
    |  |  | $categories->setItems($collection); | 
    
    |  |  | foreach ($categories->getItems() as $item) | 
    
    |  |  | { | 
    
    |  |  | $urls[] = $baseUrl . $item->getUrl(); | 
    
    |  |  | } | 
    
    |  |  | unset($collection); | 
    
    |  |  | 
 | 
    
    |  |  | // get products | 
    
    |  |  | $collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId); | 
    
    |  |  | $products = new Varien_Object(); | 
    
    |  |  | $products->setItems($collection); | 
    
    |  |  | foreach ($products->getItems() as $item) | 
    
    |  |  | { | 
    
    |  |  | $urls[] = $baseUrl . $item->getUrl(); | 
    
    |  |  | } | 
    
    |  |  | unset($collection); | 
    
    |  |  | 
 | 
    
    |  |  | // get cms pages | 
    
    |  |  | $collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId); | 
    
    |  |  | foreach ($collection as $item) | 
    
    |  |  | { | 
    
    |  |  | $urls[] = $baseUrl . $item->getUrl(); | 
    
    |  |  | } | 
    
    |  |  | unset($collection); | 
    
    |  |  | } | 
    
    |  |  | 
 | 
    
    |  |  | // output | 
    
    |  |  | switch($export_to) | 
    
    |  |  | { | 
    
    |  |  | case 'file': | 
    
    |  |  | $ioWrite = new Varien_Io_File(); | 
    
    |  |  | $path = ''; | 
    
    |  |  | $ioWrite->open(array('path' => $path)); | 
    
    |  |  | $ioWrite->streamOpen($path . 'urls.txt'); | 
    
    |  |  | foreach($urls as $url) | 
    
    |  |  | { | 
    
    |  |  | $ioWrite->streamWrite(htmlspecialchars($url . "\r\n")); | 
    
    |  |  | } | 
    
    |  |  | $ioWrite->close(); | 
    
    |  |  | break; | 
    
    |  |  | default: | 
    
    |  |  | header_remove(); | 
    
    |  |  | header('Content-Type: text/plain', true, 200); | 
    
    |  |  | header('Expires: 0'); | 
    
    |  |  | header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'); | 
    
    |  |  | header('Pragma: no-cache'); | 
    
    |  |  | while(ob_get_level() > 0) | 
    
    |  |  | { | 
    
    |  |  | @ob_end_clean(); | 
    
    |  |  | } | 
    
    |  |  | foreach($urls as $url) | 
    
    |  |  | { | 
    
    |  |  | echo htmlspecialchars($url . "\r\n"); | 
    
    |  |  | } | 
    
    |  |  | exit(); | 
    
    |  |  | } | 
    
    |  |  | ?> |