This blog is all about magento , php javescript ,mysql codes. In this i am trying to post the posts which i really feel to have these codes always with me and i am trying to publish most challenging codes which we need to use in daily development. I personally sometime needs to spent most of times to get the idea about these codes on net,thats why i thought to put all these codes on one place and i am trying to keep this work going on and in simple way which can help the communty
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 ));
While getting the product id one by one in the loop how can we get the store id of each product inside the loop?
ReplyDeleteMy 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());
}
i'm using this method to get the store id by it's returning me the array of all the stores.
ReplyDelete$product->getstoreIds();