Saturday 9 July 2011

how to get store information in magento?

Use below code for get store data :
Get store data
 
Mage::app()->getStore();
 
Store Id
 
Mage::app()->getStore()->getStoreId();
 
Store code
 
Mage::app()->getStore()->getCode();
 
Website Id
 
Mage::app()->getStore()->getWebsiteId();
 
Store Name
 
Mage::app()->getStore()->getName();
 
Is Active
 
Mage::app()->getStore()->getIsActive();
 
Store Home Url
 
Mage::app()->getStore()->getHomeUrl();

Friday 8 July 2011

How to export Categories with Ids in Magento?

Using the following given quick PHP script you can export categories with Ids in Magento.You just need to save te below given code in a PHP file “CatList.php” in the base Magento directory of your store, and visit the URL in your web browser.

<?php
 
 define('MAGENTO', realpath(dirname(__FILE__)));
 require_once MAGENTO . '/app/Mage.php';
 Mage::app();
 
 $category = Mage::getModel ( 'catalog/category' );
 $tree = $category->getTreeModel ();
 $tree->load ();
 
 $ids = $tree->getCollection ()->getAllIds ();
 
 if ($ids) {
  $file = "var/import/catlist.csv";
  file_put_contents($file,"catId, catName\n");
  foreach ( $ids as $id ) {
    $string = $id . ', ' .$category->load($id)->getName() . "\n";
   file_put_contents($file,$string,FILE_APPEND);
  }
 }
?>

You can run this script as http://www.domain.com/CatList.php. You can find the csv file in the var/import/ directory.