0
public function productDataToJson(Varien_Event_Observer $observer)
{
  $category = Mage::getModel('catalog/category');
  $tree = $category->getTreeModel();
  $tree->load();
  $ids = $tree->getCollection()->getAllIds();
  $jsonFilePath = Mage::getBaseDir().'/jsondata';
  foreach ($ids as $id) {
    $array = array();
    $products = $category->load($id)
        ->getProductCollection()
         ->addAttributeToSelect('*')
         ->addStoreFilter(Mage::app()->getStore()->getId());
    foreach ($products as $_product) {
        $array[] = array_merge($_product->getData(), array('category_ids' => $_product->getCategoryIds()));
    }
    $jsonData = Mage::helper('core')->jsonEncode($array);
    file_put_contents($jsonFilePath.'/c_' . $id . '_node.json', $jsonData);
  }
}

I am getting all this data in json file, but need price with currency, and size, color with its value lable eg. black, red. Now I am getting only ids of this 2 atttributes

7
  • $formattedPrice = Mage::helper('core')->currency($finalPrice, true, false); – Nagaraju K Jul 17 '17 at 6:29
  • Thanks @NAGARAJU KASA, Where to put this? – onlyfordigitalworld Jul 17 '17 at 6:33
  • @NAGARAJU KASA, its not working :( – onlyfordigitalworld Jul 17 '17 at 6:50
  • let me know exact event name u r using – Nagaraju K Jul 17 '17 at 6:52
  • May I know what is the exact requirement or task so that i will help u thanks – Nagaraju K Jul 17 '17 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.