I'm creating custom block to get products based on the brand name
I'd like to pass the brand name parameter from the cms page like below
{{block type="core/template" template="catalog/brand/brandprod_listing.phtml" brand_name="mybrandname2"}}
However not sure how would i load my product collection in Block Model file dynamicallay receiving the brand_name
parameter
Here is my model.
$collection = Mage::getModel('catalog/product')->getCollection();
$_productCollection = $collection->addAttributeToFilter('brand','mybrandname');
However as can be seen, how to get the parameter passed from cms page and load the results ?
Best Answer
This should help you:
If you want to get the
my_var
inphp block
directly inphp block file
then try this:Did you notice **capital
M
andV
? This is magento default magic method.Or you simply want to display
$my_var
value in yourphtml
filecatalog/brand/brandprod_listing.phtml
For example:
Note
Is attribute name is really
brand
? I believe it should bemanufacturer
for brands.[UPDATE 1]
How are you calling
product collection
? Are you calling in.phtml
file? If you are, I would suggest to call it inblock
files.[UPDATE 2]
To have this
$my_var
in your model you need to call it from block.In
.phtml
call a functionIn
.php
, block file, write this function:and now in model file: