product details
<?php
require_once("../../app/Mage.php");
umask(0);
Mage::app();
ini_set('display_errors', 1);
$productId = $_REQUEST['productid'];
$model = Mage::getModel('catalog/product') ;
$_product = $model->load($productId);
$prod_data['id']=$_product->getId();
$prod_data['name']=$_product->getName();
$prod_data['price']=$_product->getPrice();
$sp=0;
$sp=$_product->getSpecialPrice();
//echo $_product->getPrice(); //product's regular Price
if($sp<=0)
{
$sp=$_product->getPrice();
}
$prod_data['special_price']=$sp;
$prod_data['images'][0]['img']=(string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
$prod_data['images'][1]['img']=(string)Mage::helper('catalog/image')->init($_product, 'small_image');
$prod_data['images'][2]['img']=(string)Mage::helper('catalog/image')->init($_product, 'image');
$data['simple_product']=$prod_data;
$_product->img=(string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
$_product->img1=(string)Mage::helper('catalog/image')->init($_product, 'small_image');
$_product->img2=(string)Mage::helper('catalog/image')->init($_product, 'image');
//$data['simple_product'] = $_product->getData();
if($_product->isConfigurable()){
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$_product);
$sproducts = array();
$i=0;
foreach($childProducts as $child) {
$child = $obj->load($child->getId());
$sproducts[$i]['id'] = $child->getId();
$sproducts[$i]['price'] = $child->getPrice();
$sproducts[$i]['special_price'] = (string)$child->getFinalPrice();
$sproducts[$i]['option_id'] = $child->getSize();
$sproducts[$i]['option_value'] = $child->getAttributeText('size');
$sproducts[$i]['attribute_id'] = Mage::getResourceModel('eav/entity_attribute')
->getIdByCode('catalog_product', 'size');
$i++;
}
$data['child'] = $sproducts;
}
echo json_encode($data);
<?php
require_once("../../app/Mage.php");
umask(0);
Mage::app();
ini_set('display_errors', 1);
$productId = $_REQUEST['productid'];
$model = Mage::getModel('catalog/product') ;
$_product = $model->load($productId);
$prod_data['id']=$_product->getId();
$prod_data['name']=$_product->getName();
$prod_data['price']=$_product->getPrice();
$sp=0;
$sp=$_product->getSpecialPrice();
//echo $_product->getPrice(); //product's regular Price
if($sp<=0)
{
$sp=$_product->getPrice();
}
$prod_data['special_price']=$sp;
$prod_data['images'][0]['img']=(string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
$prod_data['images'][1]['img']=(string)Mage::helper('catalog/image')->init($_product, 'small_image');
$prod_data['images'][2]['img']=(string)Mage::helper('catalog/image')->init($_product, 'image');
$data['simple_product']=$prod_data;
$_product->img=(string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
$_product->img1=(string)Mage::helper('catalog/image')->init($_product, 'small_image');
$_product->img2=(string)Mage::helper('catalog/image')->init($_product, 'image');
//$data['simple_product'] = $_product->getData();
if($_product->isConfigurable()){
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$_product);
$sproducts = array();
$i=0;
foreach($childProducts as $child) {
$child = $obj->load($child->getId());
$sproducts[$i]['id'] = $child->getId();
$sproducts[$i]['price'] = $child->getPrice();
$sproducts[$i]['special_price'] = (string)$child->getFinalPrice();
$sproducts[$i]['option_id'] = $child->getSize();
$sproducts[$i]['option_value'] = $child->getAttributeText('size');
$sproducts[$i]['attribute_id'] = Mage::getResourceModel('eav/entity_attribute')
->getIdByCode('catalog_product', 'size');
$i++;
}
$data['child'] = $sproducts;
}
echo json_encode($data);
No comments:
Post a Comment