How to load a variable into the message via custom module?

1

I am making a module for displaying the stock quantity on the product page only if the quantity is less than the one defined in the options. beauty, but my question is: O estoque está com menos que %s unidades . I want to know how do I reference the variable% s within my message !? code used to build config.xml

    <stockmessages>
        <option>
            <stockmessages_enable>1</stockmessages_enable>
            <stockmessages_min_qty>5</stockmessages_min_qty>
            <stockmessages_message>The stock is below than %s items</stockmessages_message>
        </option>
    </stockmessages>

This allows me to load a default message, right, and follow the code when using it in my default.phtml:

<p class="availability in-stock"><?php $quantity=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); if($quantity<= Mage::getStoreConfig('stockmessages/option/stockmessages_min_qty')) { echo Mage::getStoreConfig('stockmessages/option/stockmessages_message') . intval($quantity) . " ";} ?></p>

The question is how to insert a variable into the custom message and pick up the option for the value to load into the final message. Thanks

    
asked by anonymous 25.02.2015 / 09:25

1 answer

0

I think what you want is something like this:

<p class="availability in-stock">
    <?php 
        $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); 
        if($quantity <= Mage::getStoreConfig('stockmessages/option/stockmessages_min_qty')) { 
            $frase = Mage::getStoreConfig('stockmessages/option/stockmessages_message') . intval($quantity) . " ";
            echo $this ou Mage:helper('seu modulo')->__($frase . ' %s', $quantity);
        } 
    ?>
</p>

You can else by placing the default message.

    
26.02.2015 / 18:07