0
要扭轉單選按鈕字段的值:
Magento的定製評分單選按鈕
現在在Magento缺省情況:
1星=> 6
2星級=> 7
3星=> 8
4星級=> 9
5星級=> 10
預期定製:
5星級=> 10
4星級=> 9
3星級=> 8
2星級=> 7
1星=> 6
我試圖把arsort
但在徒勞的。
Code :
路徑:法師/審查/座/ form.php的
public function getRatings()
{
$ratingCollection = Mage::getModel('rating/rating')
->getResourceCollection()
->addEntityFilter('product')
->setPositionOrder()
->addRatingPerStoreName(Mage::app()->getStore()->getId())
->setStoreFilter(Mage::app()->getStore()->getId())
->load()
->addOptionToItems();
return $ratingCollection;
}
路徑:form.phtml(模板文件的代碼)
<?php foreach ($this->getRatings() as $_rating): ?>
<tr>
<th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?></th>
<?php foreach ($_rating->getOptions() as $_option): ?>
<td class="value"><input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" /></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
自帶的價值單選按鈕:value="<?php echo $_option->getId() ?>"
ie:按升序排列(默認):11,12,13,14,15
應該來:15,14,13,12,11。
請貼出相關代碼 – billyonecan
@billyonecan:添加了更新的部分。 –