【问题标题】:Magento Unable to post reviewMagento 无法发表评论
【发布时间】:2016-03-09 13:46:13
【问题描述】:

我正在尝试在 magento 中为产品添加评论。但是,在前端提交产品的评论表单给我一个“无法发布评论消息”。

我还没有找到问题的解决方案,这就是我求助于你的原因:)

这是我的评论表单中的代码:

<div class="form-add">
<h2><?php echo $this->__('Write Your Own Review') ?></h2>
<?php if ($this->getAllowWriteReviewFlag()): ?>
    <form action="<?php echo $this->getAction() ?>" method="post" id="review-form">
        <?php echo $this->getBlockHtml('formkey'); ?>
        <?php echo $this->getChildHtml('form_fields_before') ?>
        <h3><?php echo $this->__("You're reviewing:"); ?>
            <span><?php echo $this->escapeHtml($this->getProductInfo()->getName()) ?></span>
        </h3>

        <div class="fieldset">
            <?php if ($this->getRatings() && $this->getRatings()->getSize()): ?>
                <h4><?php echo $this->__('How do you rate this product?') ?> <em class="required">*</em></h4>
                <span id="input-message-box"></span>
                <table class="data-table review-summary-table ratings" id="product-review-table">
                    <col width="1"/>
                    <col/>
                    <col/>
                    <col/>
                    <col/>
                    <col/>
                    <thead>
                    <tr>
                        <th>&nbsp;</th>
                        <th>
                            <div class="rating-box">
                                <span class="rating-number">1</span>
                                <span class="rating nobr"
                                      style="width:20%;"><?php echo $this->__('1 star') ?></span>
                            </div>
                        </th>
                        <th>
                            <div class="rating-box">
                                <span class="rating-number">2</span>
                                <span class="rating nobr"
                                      style="width:40%;"><?php echo $this->__('2 star') ?></span>
                            </div>
                        </th>
                        <th>
                            <div class="rating-box">
                                <span class="rating-number">3</span>
                                <span class="rating nobr"
                                      style="width:60%;"><?php echo $this->__('3 star') ?></span>
                            </div>
                        </th>
                        <th>
                            <div class="rating-box">
                                <span class="rating-number">4</span>
                                <span class="rating nobr"
                                      style="width:80%;"><?php echo $this->__('4 star') ?></span>
                            </div>
                        </th>
                        <th>
                            <div class="rating-box">
                                <span class="rating-number">5</span>
                                <span class="rating nobr"
                                      style="width:100%;"><?php echo $this->__('5 star') ?></span>
                            </div>
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($this->getRatings() as $_rating): ?>
                        <tr>
                            <th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?></th>
                            <?php foreach ($_rating->getOptions() as $_option): ?>
                                <td class="value"><label
                                        for="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>"><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"/></label></td>
                            <?php endforeach; ?>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
                <input type="hidden" name="validate_rating" class="validate-rating" value=""/>
                <script type="text/javascript">decorateTable('product-review-table')</script>
            <?php endif; ?>

            <ul class="form-list">
                <li>
                    <label for="review_field"
                           class="required"><em>*</em><?php echo $this->__('Let us know your thoughts') ?></label>
                    <div class="input-box">
                        <textarea name="detail" id="review_field" cols="5" rows="3"
                                  class="required-entry"><?php echo $this->escapeHtml($data->getDetail()) ?></textarea>
                    </div>
                </li>

                <li class="inline-label">
                    <label for="summary_field"
                           class="required"><em>*</em><?php echo $this->__('Summary of Your Review') ?></label>
                    <div class="input-box">
                        <input type="text" name="title" id="summary_field" class="input-text required-entry"
                               value="<?php echo $this->escapeHtml($data->getTitle()) ?>"/>
                    </div>
                </li>

                <li class="inline-label">
                    <label for="nickname_field"
                           class="required"><em>*</em><?php echo $this->__("What's your nickname?") ?></label>
                    <div class="input-box">
                        <input type="text" name="nickname" id="nickname_field" class="input-text required-entry"
                               value="<?php echo $this->escapeHtml($data->getNickname()) ?>"/>
                    </div>
                </li>

            </ul>
        </div>
        <div class="buttons-set">
            <button type="submit" title="<?php echo $this->__('Submit Review') ?>" class="button">
                <span><span><?php echo $this->__('Submit Review') ?></span></span></button>
        </div>
    </form>
    <script type="text/javascript">
        //<![CDATA[
        var dataForm = new VarienForm('review-form');
        Validation.addAllThese(
            [
                ['validate-rating', '<?php echo $this->__('Please select one of each of the ratings above') ?>', function (v) {
                    var trs = $('product-review-table').select('tr');
                    var inputs;
                    var error = 1;

                    for (var j = 0; j < trs.length; j++) {
                        var tr = trs[j];
                        if (j > 0) {
                            inputs = tr.select('input');

                            for (i in inputs) {
                                if (inputs[i].checked == true) {
                                    error = 0;
                                }
                            }

                            if (error == 1) {
                                return false;
                            } else {
                                error = 1;
                            }
                        }
                    }
                    return true;
                }]
            ]
        );
        //]]>
    </script>
<?php else: ?>
    <p class="review-nologged" id="review-form">
        <?php echo $this->__('Only registered users can write reviews. Please, <a href="%s">log in</a> or <a href="%s">register</a>', $this->getLoginLink(), Mage::helper('customer')->getRegisterUrl()) ?>
    </p>
<?php endif ?>

看起来像标准的 rwd 主题布局。如果我删除了我的自定义一个,所以 rwd 默认弹出它仍然不起作用。

我发帖的网址如下:

https://www.example.com/review/product/post/id/73/

希望有人可以在正确的方向上帮助我。快把我逼疯了!!!

【问题讨论】:

  • 您是否启用了日志和开发者模式以查看抛出了什么错误?在 magento 管理员评论中启用了吗?您可以在管理员中看到它们并进行审核吗?
  • 我将在测试环境中启用日志和开发者模式。我可以在管理表单中接受和添加评论。希望日志能说明更多信息。谢谢!
  • @Andrei,我启用了日志,而 system.log 没有显示任何与评论或其任何控制器相关的内容。
  • 您可以尝试启用此处描述的错误 - blog.belvg.com/how-to-enable-error-messages-in-magento.html

标签: forms magento templates post review


【解决方案1】:

我自己解决了这个问题。

这与评论本身无关。我的第一个想法是一个模块阻止了对评论的访问,在 de controller 中搜索评论后,我们发现问题是一个模块无法在数据库中存储一定长度的字符。这在某种程度上与评论帖子相冲突。

在联系了该模块的开发人员后,我们得以解决问题。该模块是 MailPlus,我们通过转到模块的配置解决了这个问题,并为主网站编辑了以下内容:

更改此设置后,评论表单再次开始工作。

感谢大家帮助我!

【讨论】:

    猜你喜欢
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    • 1970-01-01
    相关资源
    最近更新 更多