Question

I'm attempting to assign some variable used in a custom modules model. This variable will be defined in the CMS page. How can I pass this variable in such a way as it will be used in the model? I'm assigning the variable like this:

{{block type="catalog/layer_view" name="view" myvariable="5" template="catalog/layer/view.phtml"}}

How can I access this variable within the model?

Specifically.. here:

class Mage_Catalog_Model_Layer extends Varien_Object{
    public function prepareProductCollection($collection){
        //access variable
    }

}
Was it helpful?

Solution

you are declaring blocks. Blocks (in theory) have nothing to do with models. So you can access the variable in the block with $this->getMyvariable().
In order to access it in the model you need to pass it from the block to the model.
Look for the code that relates your block to the model and pass it to that model.

If you are using only core models that's not possible without overrides.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top