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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?