0

How can i get specific product attribute list and price with product id ? is it possible to get product options like color , size and ... only with product id ? i want to add a php code to root of magento on host and when call it from browser it`s show me details of product .

1

I'm not 100% sure about your question but I try to help you:

How can i get specific product attribute list and price with product id ? is it possible to get product options like color , size and ... only with product id ?

//load product by ID
$_product = Mage::getModel('catalog/product')->load($productID);

//get attributes
$_product->getColour();
$_product->getSize(); 

i want to add a php code to root of magento on host and when call it from browser it`s show me details of product .

Seems you want to create a script that gives you the selected infos from above. Your script could be something like:

<?php
require_once('app/Mage.php');
Mage::app();

//get product id "id" from GET parameter
//set plausible_max_product_id
if($productID = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT, array("options" => array("min_range"=>1, "max_range"=>plausible_max_product_id)))) {
   die("Product ID not allowed");
}

$_product = Mage::getModel('catalog/product')->load($productID);

//get attributes
echo $_product->getName();
echo $_product->getColour();
echo $_product->getSize(); 
  • Thank you its work fine , but when i try use getColour or getSize its return null . – mahdi Aug 14 '14 at 6:50

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.