public function productDataToJson(Varien_Event_Observer $observer)
{
$array = array();
$products = Mage::getModel('catalog/product')->getCollection();
foreach ($products as $_product) {
$array[] = $_product->getData();
}
$gallery_images = Mage::getModel('catalog/product')->getMediaGalleryImages();
$items = array();
foreach ($gallery_images as $g_image) {
$items[] = $g_image['url'];
}
$jsonData = Mage::helper('core')->jsonEncode($array,$items);
echo $jsonData;
file_put_contents("c_node.json", $jsonData);
exit;
}
Add a comment
|
1 Answer
public function productDataToJson(Varien_Event_Observer $observer)
{
$array = array();
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addStoreFilter(Mage::app()->getStore()->getId());
foreach ($products as $_product) {
$array[] = $_product->getData();
}
$jsonData = Mage::helper('core')->jsonEncode($array);
echo $jsonData;
file_put_contents("c_node.json", $jsonData);
exit;
}
I got all data from this. If this wrong, please let me know. Thank you.