在magento中获取帮助数据php

时间:2014-05-03 11:12:57

标签: magento math php adminhtml

一直试图从magento

中的.phtml文件中的两个辅助函数中获取可变百分比

基本上我有两个基于两个辅助函数的变量,它们在自己的输出/回显静态数字上。问题在于下面的php,它们只显示为值而不是分割/乘法。就像我说的帮助数据&模块工作是使用数据作为变量来完成/完成.phtml文件中的等式。见下面的代码

get->FunctionA()只等于一个圆数值(来自集合)

get->FunctionB()也等于圆数值(来自集合)

probs不是最好的方法,但这只是从辅助数据中输出两个值而不是分割。

echo Mage::helper('module/data')->getFunctionA() / Mage::helper('module/data')->getFunctionB();

这也不起作用,只产生相同的结果,并且是最好/最简单的方式

$dataA = Mage::helper('module/data')->getFunctionA(); 
$dataB = Mage::helper('module/data')->getFunctionB();
$result = ($dataA / $dataB) * 100;
echo $result;

就像我上面说的那样,值可以回显(在辅助函数或phtml文件中,但实际计算并不会起作用

任何帮助都会很棒

1 个答案:

答案 0 :(得分:1)

好的问题排除了。发生的事情是在帮助文件中getFunctionA()&当我应该只返回值然后回显.phtml文件中的辅助函数时,正在回显getFunctionB()值。卫生署!请参阅下面正在使用的帮助函数示例Woohoo !!!

public function getFunctionA()
{
$FunctionA = Mage::getModel('module/collection')->getCollection();
$FunctionA->addFieldToFilter('attribute', 'value_to_filter');
$FunctionA->addFieldToFilter('status','1');
return ''.count($FunctionA) . ''; //this line was the problem cause i was echoing & not returning the value

}

现在价值可以在phtml&数学方程确认正在运作

$dataA = Mage::helper('module/data')->getFunctionA(); 
$dataB = Mage::helper('module/core')->getFunctionB();
$result = ($dataA / $dataB) * 100;
echo $result;

这段代码算了算,现在我可以休息了。