0

So I am trying to get a reference to the current product in my Block with

$product = Mage::registry("current_product");

Which seems to work fine, but the $product->getShortDescription is returning null.

I tried debugging this myself by stepping through the product helper initProduct method and upon inspecting the Product Model, the data is as expected. i.e:

_data["short_description"] = "SOME SHORT DESCRIPTION"

After registering the product

# app/code/core/Mage/Catalog/Helper/Product.php
344| // Register current data and dispatch final events
345| Mage::register('current_product', $product);
346| Mage::register('product', $product);

the short description seem to be lost.

_data["short_description"] = null

Has anyone else had this issue? It would be cool to know how to solve it.

NOTE: It could have something to do with the Model rewriting that happens with the registry...

Thanks guys.

0

you are calling the attribute direct in the product page you have to enable it first from backend. go to admin->catalog->manage attribute and find for short description.

when you click it you will find "Visible on Product View Page on Front-end" make it yes . i hope this will work for you.

enter image description here

  • Sorry, should have said I ensured it is Visible on Product View Page on Frontend – Nathaniel Rogers Nov 23 '16 at 5:07
0

You have to load product after that you will get short description

$productId = Mage::registry("current_product")->getId();

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

echo $product->getShortDescription();
  • Thanks for your answer so quickly. This definitely would work, it's just to my understanding, when we register a model through the registry, it is a 'state' of that model, meaning if the model is saved after loading, I thought it would be loaded when getting it from the registry again. I have a sneaking suspicion there's a bug in the registering of models. I was hoping I could avoid having to 're'-load the product after getting it from the registry. – Nathaniel Rogers Nov 23 '16 at 5:10
  • You have tried with $product->getShortDescription() bracket in end of description? – Prashant Valanda Nov 23 '16 at 5:16
  • oh, most definitely. I think there might be a core issue with textarea values being saved in the registry. It seems to work fine if my short description doesn't have line separators in them. I know a little bit more about coding than to look for a property when I meant a function. Didn't think it would matter as I was explaining a process rather than detailing the actual code I wrote :) So in short, yes I ran the function $this->getShortDescription() – Nathaniel Rogers Nov 23 '16 at 5:29

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.