cancel
Showing results for 
Search instead for 
Did you mean: 

Output of a custom attribute

SOLVED

Output of a custom attribute

Hello there,

I made a custom attribute called 'baseprice' which I want to show below the normal product price in the price_info box that also holds the taxt information.

 

Those information are rendered in the 'frontend/base/default/template/magesetup/price_info.phtml'

 

 This is the content of the file:

 

<?php
/**
 * This file is part of a FireGento e.V. module.
 *
 * This FireGento e.V. module is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This script is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * @category  FireGento
 * @package   FireGento_MageSetup
 * @author    FireGento Team <team@firegento.com>
 * @copyright 2013-2015 FireGento Team (http://www.firegento.com)
 * @license   http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
 */
?>
<?php
/**
 * @var $this FireGento_MageSetup_Block_Catalog_Product_Price
 */
?>
<?php $shippingCostUrl = Mage::helper( 'magesetup' )->getShippingCostUrl() ?>
<?php if( !empty( $shippingCostUrl ) && $this->getIsShowShippingLink() ): ?>
    <?php if( $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX ): ?>
        <?php if( $this->getIsIncludingShippingCosts() ): ?>
            <span class="tax-details"><?php echo $this->__( 'Excl. %s Tax', $this->getFormattedTaxRate() ) ?><span class="tax-separator">, </span><span class="shipping-cost-details"><?php echo $this->__( 'incl. <a href="%s">Shipping Cost</a>', $shippingCostUrl ) ?></span></span>
        <?php else: ?>
            <span class="tax-details"><?php echo $this->__( 'Excl. %s Tax', $this->getFormattedTaxRate() ) ?><span class="tax-separator">, </span><span class="shipping-cost-details"><?php echo $this->__( 'excl. <a href="%s">Shipping Cost</a>', $shippingCostUrl ) ?></span></span>
        <?php endif ?>
    <?php elseif( $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX ): ?>
        <?php if( $this->getIsIncludingShippingCosts() ): ?>
            <span class="tax-details"><?php echo $this->__( 'Incl. %s Tax', $this->getFormattedTaxRate() ) ?><span class="tax-separator">, </span><span class="shipping-cost-details"><?php echo $this->__( 'incl. <a href="%s">Shipping Cost</a>', $shippingCostUrl ) ?></span></span>
		<?php else: ?>
            <span class="tax-details"><?php echo $this->__( 'Incl. %s Tax', $this->getFormattedTaxRate() ) ?><span class="tax-separator">, </span><span class="shipping-cost-details"><?php echo $this->__( 'excl. <a href="%s">Shipping Cost</a>', $shippingCostUrl ) ?></span></span>
		<?php endif ?>
    <?php elseif( $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH ): ?>
        <?php if( $this->getIsIncludingShippingCosts() ): ?>
            <span class="tax-details"><?php echo $this->__('incl. <a href="%s">Shipping Cost</a>', $shippingCostUrl) ?></span>
        <?php else: ?>
            <span class="tax-details"><?php echo $this->__('excl. <a href="%s">Shipping Cost</a>', $shippingCostUrl) ?></span>
        <?php endif ?>
    <?php endif ?>
    <?php if ($this->getIsShowWeightInfo()): ?>
        (<?php echo $this->__('Shipping Weight %s', $this->getFormattedWeight()) ?>)
    <?php endif ?>
<?php else: ?>
    <?php if( $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX ): ?>
        <span class="tax-details"><?php echo $this->__( 'Excl. %s Tax', $this->getFormattedTaxRate() ) ?></span>
    <?php elseif( $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX ): ?>
        <span class="tax-details"><?php echo $this->__( 'Incl. %s Tax', $this->getFormattedTaxRate() ) ?></span>
    <?php endif ?>
<?php endif ?>

 I noticed that if I want to show the information at the place I want to show them add,  I have to add it after the 'tax-detail' lines (one of them marked in bold above).

 

Unfortunately I have not much experience working with php. I know that I have to get my attribute 'baseprice' for the current product and just show it there. The problem is, that I was not successful in getting the attribute and printing it. Whatever I tried, I got an error and the page stopped rendering at the price_info box.
I know it is not a hard problem, I just don't know what information I already have and how to do it exactly.


Hopefully someone can help me out here.
Thanks!

2 REPLIES

Re: Output of a custom attribute

I don't know how your extension is working and what $this returns.

But I think this will be help full to you.

Try solution and add this code to your place:

 

1) 

 

$id = Mage::registry('current_product')->getId();
$baseprice = Mage::getModel('catalog/product')->load($id)->getBaseprice();

 

OR

 

2)

 

$id = $this->getProduct()->getId();
$baseprice = Mage::getModel('catalog/product')->load($id)->getBasepricce();

 

 

Re: Output of a custom attribute

Hello, I tried your edits and was able to display my baseprice attribute in the product page. A new problem I encountered was that after my edits the catalogue wasn't displayed correctly anymore. I think the reason is that the price_info block wasn't being displayed anymore. It might have to do with the theme I am using. I have to take a look at it this. Thanks for the advice, you were still able to help me.