Friday 21 December 2012

how to get store id in magento

$storeId = Mage::app()->getStore($storeCode)->getId();

echo $storeId;

2 comments:

  1. While getting the product id one by one in the loop how can we get the store id of each product inside the loop?
    My code is given below
    $collection = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
    ->addAttributeToFilter('visibility', array(
    Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
    ));

    foreach ($collection as $product ) {

    $store_name = Mage::app()->getStore()->getName();
    echo 'Store Name --> '.$store_name; echo '
    ';
    echo ' Product ID-->'.$product->getId().' Product Name--> '.$product->getName(); echo '
    ';

    $sitemap->addUrl($product->getProductUrl(), $product_priority, $product->getUpdatedAt());

    }

    ReplyDelete
  2. i'm using this method to get the store id by it's returning me the array of all the stores.
    $product->getstoreIds();

    ReplyDelete