dqo88037 2014-12-09 12:19
浏览 88
已采纳

语法错误,意外T_PRIVATE - Magento

My problem is with two functions :

<?php
private function getAttributes() {
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
    ->setEntityTypeFilter('4') 
    ->addSetInfo()
    ->getData();

$attr = array();
$currStoreViewId = Mage::app()->getStore()->getId();
foreach($attributesInfo as $attribute):
    $attribute = Mage::getModel('eav/entity_attribute')->load($attribute['attribute_id']);
    if (!$attribute->getIsVisibleOnFront()) continue;
    $labels = $attribute->getStoreLabels();
    if (isset($labels[$currStoreViewId])) $label = $labels[$currStoreViewId];
    else $label = $attribute->getFrontendLabel();
    $attr[ $attribute->getAttributeCode() ] = $label;
endforeach;
return $attr;
}

public function getProductAttributList($_product) {
$pid = $_product->getId();
if (empty($pid)) return false;
$attributes = $this->getAttributes();
if (count($attributes)>0) $html = '<table width="100%" cellpadding="0" cellspacing="0">';
else return false;
foreach($attributes as $attrcode => $attrlabel) {
    $value = $_product->{'get'.$attrcode}();
    if ($attrcode=='weight') continue;
    if (empty($value)) continue;
    if (is_numeric($value)) $value = $_product->getAttributeText($attrcode);
    $html .= '<tr><td style="width:50%; padding:0 10px 0 0;"><strong>'.$attrlabel.'</strong>
</td><td style="padding:0; width:50%;">'.$value.'</td>';
}
return $html.'</table>';
}
?>

I still get the error : syntax error, unexpected T_PRIVATE. Can anyone help me solve this ? I have the same problem with the public function.

  • 写回答

1条回答 默认 最新

  • dongmei9203 2014-12-09 12:22
    关注

    Function can't be public/protected/private. This modifiers can be applyed only for class methods.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line