Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When the layout rendering code encounters this</p> <pre><code>&lt;block type="layout/carousel" name="featured_carousel"&gt; </code></pre> <p>It <strong>immediately</strong> instantiates the block. That means the block's <code> __construct</code> method is called <strong>before</strong> your <code>setData</code> method is called. So, at the time of construction, no data has been set, which is why your calls to <code>var_dump</code> return an empty array.</p> <p>Also, immediately after being created, the block is added to the layout</p> <pre><code>#File: app/code/core/Mage/Core/Model/Layout.php ... $block-&gt;setLayout($this); ... </code></pre> <p>When this happens, the block's <code>_prepareLayout</code> method is called. </p> <pre><code>#File: app/code/core/Mage/Core/Block/Abstract.php public function setLayout(Mage_Core_Model_Layout $layout) { $this-&gt;_layout = $layout; Mage::dispatchEvent('core_block_abstract_prepare_layout_before', array('block' =&gt; $this)); $this-&gt;_prepareLayout(); Mage::dispatchEvent('core_block_abstract_prepare_layout_after', array('block' =&gt; $this)); return $this; } </code></pre> <p>So, this means that any data set in your layout update xml is <strong>still</strong> not available, even in <code>_prepareLayout</code>. Once the system is done creating the block, it moves on to the next XML node.</p> <pre><code>&lt;action method="setData"&gt; &lt;name&gt;filter_attribute&lt;/name&gt; &lt;value&gt;is_featured_product&lt;/value&gt; &lt;/action&gt; </code></pre> <p>and calls the <code>setData</code> method. Now your block has its data set.</p> <p>Try defining a <code>_beforeToHtml</code> method on your block and checking for data there. (Assuming your block is being rendered)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload