Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Get Data From Separate Template File / Group Product Weight
 
JamesTaylor
Jr. Member
 
Total Posts:  2
Joined:  2011-03-30
 

Hi,

I’m wanting to access data which is being generated by a separate template file, namely whilst using a group product, as I want to display the total weight of the grouped product on my product page.

From the view.phtml template, the grouped.phtml file is called and within that template file each of the group’s Associated Products is being listed out. Whilst the PHP is cycling through each of the Associated Products I want to access the weight of each product and keep a running total, I then want to pass the final total value back to the view.phtml file to be used further down the code of view.phtml

Is this possible and if so how would I pass the data back to the view.phtml template file?

The code in grouped.phtml is:

<?php foreach ($_associatedProducts as $_item): ?>
        <?php $_finalPriceInclTax 
$this->helper('tax')->getPrice($_item$_item->getFinalPrice(), true?>

        
<li><?php echo $this->htmlEscape($_item->getName()) ?>

            
<input type="hidden" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></li>

        
<?php $GroupedWeight += $this->htmlEscape($_item->getWeight()) ?>

        <?php $sum 
+= $_finalPriceInclTax ?>
    <?php 
endforeach; ?>

My variable $GroupedWeight is keeping a running total as required, i’m just not sure to pass this back to view.phtml or alternatively how to access it from view.phtml?

I’m assuming this is the best way to go about obtaining the total weight as I don’t want to have to cycle through the associated products in the view.phtml file and then again the grouped.phtml file as obviously this wouldn’t seem to be efficient if I can do it once and simply pass the data to where I want it to be used.

Thanks

James

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top