Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure if I got your question right but here goes.<br> I think you can use the event <code>[model]_load_after</code> and simply do this:</p> <pre><code>$object = $event-&gt;getObject(); $object-&gt;setIncrementId('12345'); </code></pre> <p>Or if you want to use a decorator class make it look like this:</p> <pre><code>public function __construct(Mage_Sales_Model_Order_Invoice $model) { parent::__construct($model); $model-&gt;setIncrementId($this-&gt;getIncrementId()); } public function getIncrementId() { return '12345'; } </code></pre> <p>I know that this is not exactly a decorator pattern but it should work.<br> I know that when adding a new method to the 'decorator' class you need to add it to attach data to the main model.<br> This is just my idea. I haven't got an other.</p> <p><strong>[EDIT]</strong><br> You can try to rewrite the <code>load</code> method on the object to make it return what you need. But I wouldn't go that way. You can end up screwing a lot of other things.<br> I don't think there is an other way to do it because <code>load</code> always returns the current object no mater what you do in the events dispatched in the method. see <code>Mage_Core_Model_Abstract::load()</code></p> <pre><code>public function load($id, $field=null) { $this-&gt;_beforeLoad($id, $field); $this-&gt;_getResource()-&gt;load($this, $id, $field); $this-&gt;_afterLoad(); $this-&gt;setOrigData(); $this-&gt;_hasDataChanges = false; return $this; } </code></pre> <p>By making it return <code>new Decorator($this)</code>, you might achieve what you need, but just make sure that when calling <code>$model-&gt;doSomething()</code> and <code>doSomething()</code> is not a method in your decorator you still end up calling the original method on the model.</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. This table or related slice is empty.
    1. 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