Reputation: 838
I wrote this code in my block file called "Myquestion.php" and trying to retrieve its value in the phtml file
This file lies in /app/code/local/Maven/Questionanswer/Block
public function getProductId()
{
$product_id = Mage::registry('current_product')->getId();
return $product_id;
}
public function getStoreId()
{
$storeId = Mage::app()->getStore()->getStoreId();
return $storeId;
}
}
Now I have the phtml file in /app/design/frontend/rwd/default/template/questionanswer
<input type="hidden" name="product_id" placeholder="<?php echo $this->getProductId();?>">
<input type="hidden" name="store_id" value="<?php echo $this->getSoreId(); ?>">
But failing to retrieve any value. Where am I making mistake?
Upvotes: 0
Views: 81
Reputation: 2669
First check the class in your .phtml file like,
echo get_class($this);
If it is not returning any or correct class then check your block layout file that you defined.
And make sure the function getProductId()
is really returning any values. Make sure clear you cache.
Upvotes: 1