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();
Or:
$_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.
1 Answer 1
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– Prateek2015年09月21日 08:47:04 +00:00Commented Sep 21, 2015 at 8:47
 - 
 Sure, I had a time period to wait before I could accept it.DeviateDefiant– DeviateDefiant2015年09月21日 13:19:46 +00:00Commented Sep 21, 2015 at 13:19
 
Explore related questions
See similar questions with these tags.
$_manufacturer = Mage::getModel('zeon_manufacturer/manufacturer')->load($identifier, "identifier");- thank you @Prateek.