1

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
    }

}
2

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.

  • what must I override to pass this variable from the block to the model? – easymoden00b Mar 3 '15 at 14:43
  • I just told you...look in the code where the block accesses the model and do something like $model->setMyvariable($this->getMyvariable())...then you can use the value in the model with $this->getMyvariable() – Marius Mar 3 '15 at 14:46

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.