Code work, but log says "Missing argument 3"

I use this code to show short description on my product page in Magento.

<?php $_description = $this->getProduct()->getShortDescription(); ?>
<?php if ($_description): ?>
<div class="std">
    <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description, 'short_description')) ?>
</div>
<?php endif; ?>

In my systemlog it says: Warning: Missing argument 3 for Mage_Catalog_Helper_Output::productAttribute() on line 4

But the page work fine. However i can't really see where the error are.

Upvotes: 1

Views: 198

Answers (1)

Philipp
Philipp

Reputation: 15629

It seems, you set the parenthesis wrong. 'short_description' belongs not to nl2br - it belongs to the productAttribute() call.

    echo $this->helper('catalog/output')
              ->productAttribute($this->getProduct(), nl2br($_description), 'short_description');

This error occurs, because your calling a function, which expects three params and only passing two params. As the third param has no default value, php prints a warning about the missing thrid param. Because you run magento in production mode, the warning is never printed to the user and just written to var/log/system.log

Upvotes: 2

Related Questions