0
function productDescription()
{
  $attribute = Mage::getSingleton('eav/config')
      ->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'size');
  if ($attribute->usesSource()) {
      $options = $attribute->getSource()->getAllOptions(false);
  }
  print_r($options);
  $array = json_encode($options);
  file_put_contents("product_node.json", $array);
  $attribute1 = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color'); //"color" is the attribute_code
  $allOptions = $attribute1->getSource()->getAllOptions(false);
  foreach ($allOptions as $instance) {
    $id = $instance['value']; //id of the option
    $value = $instance['label']; //Label of the option
  }
  print_r($allOptions);
  $array1 = json_encode($allOptions);
  file_put_contents("product_color.json", $array1);
}
4
  • 2
    Can you please add output JSON which you want to get? – John Jun 16 '17 at 11:41
  • [{"label":"","value":""},{"value":"24","label":"black"},{"value":"27","label":"blue"},{"value":"25","label":"green"},{"value":"28","label":"red"},{"value":"26","label":"yellow"}] also i want size values – onlyfordigitalworld Jun 16 '17 at 11:49
  • This is just for color values. How do you want to combine color and size in json? – John Jun 16 '17 at 12:34
  • I want to display all color and sizes in sidebar – onlyfordigitalworld Jun 16 '17 at 12:36

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.