1

I need products thumbnail image, SKU, name, details, if the customer enters sku on custom page.

2 Answers 2

2

Please use this code:

$_sku = 'xyz';
                $_catalog = Mage::getModel('catalog/product');
                $_productId = $_catalog->getIdBySku($_sku);
                $_product = Mage::getModel('catalog/product')->load($_productId);
                // get Product's name
                echo $_product->getName();
                //get product's short description
                echo $_product->getShortDescription();
                //get Product's Long Description
                echo $_product->getDescription();
                //get Product's Regular Price
                echo $_product->getPrice();
                //get Product's Special price
                echo $_product->getSpecialPrice();
                //get Product's Url
                echo $_product->getProductUrl();
                //get Product's image Url
                echo $_product->getImageUrl();
5
6

I am assuming that the customer is entering the sku of product and that sku you are getting in post value. so for getting more details of product from the sku you can use the following code :

$sku = 'abc'; // The sku entered by customer
$productCollection = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);

Now you will have product object through which you can get your data for example

$thumbnail = $productCollection->getThumbnailUrl();
$name = $productCollection->getName();

and similarly other relevent details of product.

Hope it works for you !!

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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