I'll prefix this by saying I'm a frontend guy, so forgive my general lack of knowledge but I am trying to learn. I'm using an addon called 'Zeon Manufacturer' (CE 1.9.2), basically associates a chosen manufacturer product attribute with further data about the manufacturer.

I'm trying to manipulate the manufacturers detail pages to add Schema/OpenGraph data but having trouble accessing the model within a block I've added to the head.phtml, the only place that data can go. For example:

<meta property="og:description" content="<?php echo $_manufacturer->getDescription(); ?>">

On the page content block itself, view.phtml, the variables I need are accessed as such:

$_manufacturer = $this->getManufacturer();
$example = echo $_manufacturer->getDescription();

I've also been able to access the model on product pages no issue using:

$manufacturerId = $_product->getManufacturer();
$_manufacturer = Mage::getModel('zeon_manufacturer/manufacturer')->load($manufacturerId, "manufacturer");
$example = echo $_manufacturer->getDescription();

However on my custom block, meta.phtml, I can't any method I try to work:

$_manufacturer = $this->getManufacturer();


$_manufacturer = Mage::getModel('zeon_manufacturer/manufacturer')->load('example', "manufacturer");

I'm sure there's some core PHP concept I'm missing, perhaps the scope where I can access the model or limitations imposed on the head child blocks before the page content is generated?

I'm trying to learn so please forgive any naivity.

  • $this will only work if you have those methods in corresponding blocks. Your second approach is reasonable, just make sure that 'example' is actually an ID in your manufacturer table. It would probably be an integer. – Prateek Sep 18 '15 at 8:03
  • That's the thing @Prateek, I can't get it to give me any output using the attribute's ID or its identifier. – DeviateDefiant Sep 18 '15 at 9:38
  • It will not be attribute ID or identifier, it will be the primary key that will be passed as "example" in the table associated to zeon_manufacturer/manufacturer model. – Prateek Sep 18 '15 at 14:29
  • Finally nailed it, pulled the identifier from the page URL and looked it up like this: $_manufacturer = Mage::getModel('zeon_manufacturer/manufacturer')->load($identifier, "identifier"); - thank you @Prateek. – DeviateDefiant Sep 19 '15 at 13:05

Resolved in comments above with help from @Prateek by gaining an understanding of keys used to load data from a collection.

My solution isn't the cleanest method in the world, but it works:

$identifier = Mage::helper('core/url')->getCurrentUrl();
if(substr($identifier, -1) == '/') {
    $identifier = substr($identifier, 0, -1);
$identifier = explode('/',$identifier);
$identifier = end($identifier);

$_manufacturer = Mage::getModel('zeon_manufacturer/manufacturer')->load($identifier, "identifier");
  • It would also be great if you can accept this as the answer to your question so it doesn't remain unanswered. – Prateek Sep 21 '15 at 8:47
  • Sure, I had a time period to wait before I could accept it. – DeviateDefiant Sep 21 '15 at 13:19

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.