Skip to content

Instantly share code, notes, and snippets.

@webdawe
Created June 28, 2018 01:06
Show Gist options
  • Save webdawe/4c56b2b0052e25456160b9cbc92071c8 to your computer and use it in GitHub Desktop.
Save webdawe/4c56b2b0052e25456160b9cbc92071c8 to your computer and use it in GitHub Desktop.
Load Urls
<?php
require_once 'abstract.php';
class Mage_Shell_Load_Urls extends Mage_Shell_Abstract
{
private $_baseUrl;
private $_urls = array();
public function run()
{
$storeId = 1;
$this->_baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
$this->_urls[] = $this->_baseUrl;
//load category urls
$collection = Mage::getResourceSingleton('sitemap/catalog_category')->getCollection($storeId);
$this->loadUrls($collection);
unset($collection);
//load product urls
$collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);
$this->loadUrls($collection);
unset($collection);
// get cms pages urls
$collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId);
$this->loadUrls($collection);
unset($collection);
print_r($this->_urls);
}
private function loadUrls($collection)
{
foreach ($collection as $item)
{
$this->_urls[] = $this->_baseUrl . $item->getUrl();
}
}
}
$shell = new Mage_Shell_Load_Urls();
$shell->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment