0
votes

My client needs to have the sku number, next to the Product Name in the Magento Shopping Cart. I tried adding this code:

<?php echo $this->__('Style Number : %s', $_product->getSku()) ?>

but I get this message:

"Fatal error: Call to a member function getSku() on a non-object."

I would appreciate any help.

Thank you.

4
what template are you editing?Jonathan Day

4 Answers

6
votes

If you edit DOCROOT\app\design\frontend\default\themename\template\checkout\cart\item\default.phtml and add

<?php echo $_item->getSku() ?>

That should work.

JD

1
votes

http://www.woolleydesign.net/2011/05/magento-adding-short-description-to-the-shopping-cart/

Got some assistance from here as well, great post for any others interested

0
votes

The line:

<?php echo $_item->getSku() ?>

inserted in:

app\design\frontend\default\themename\template\checkout\cart\item\default.phtml

exactley above line:

<?php if ($_options = $this->getOptionList()):?>

as per the above Mike answer solved for me one of the main problems. Is working well also with SCP installed. I got, in the cart, the SKU of the selected simple object associated to a configurable product.

I am on Magento 1.6.2. PERFECT.

Thanks Jonathan, thanks Mike, thanks to all.

0
votes

Works perfect - only one piece of advice for some uncertain where to drop this code.

I added it after line 37 in default.phtml after the closure

Reason being is in the wrong place it won't show up under the product name if I add it after line 27.

My lines 37-39 on Magento 1.5 for default.phtml mentioned above

</h2>
    <?php echo $_item->getSku() ?>
<?php if ($_options = $this->getOptionList()):?>