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 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办