お客様が商品に関するレビューを投稿すると、レビューは自動的に承認される必要があります。管理者によって承認される必要はありません。商品レビューを自動設定するMagentoで自動承認
3
A
答えて
3
this approachを試すことができます。
UPDATE:リンクは有効ではなくなりました。ウェブアーカイブからリンクを投稿しました。
1
新しいモジュールを作成することは、そのシンプルで簡単な最適なアプローチです。 ステップ1:アプリの/ etc /ローカルでDPC ステップ3と呼ばれるフォルダを作成します:Dpc_Review.xml
<?xml version="1.0"?>
<config>
<modules>
<Dpc_Review>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Review/>
</depends>
</Dpc_Review>
</modules>
</config>
ステップ2と呼ばれるアプリケーションの/ etc /モジュールにモジュール宣言ファイルを作成しますアプリケーション内/ etc/local/Dpc /新しいフォルダを作成する ステップ3:アプリケーション内で/ etc/local/Dpc/Reviewを作成する3つのフォルダコントローラやその他のヘルパーを作成する ステップ4:app内/ etc/local/Dpc/Review/etc/config.xmlというファイルを作成する
<?xml version="1.0"?>
<config>
<modules>
<Dpc_Review>
<version>0.0.1</version>
</Dpc_Review>
</modules>
<frontend>
<routers>
<review>
<args>
<modules>
<Dpc_Review before="Mage_Review">Dpc_Review</Dpc_Review>
</modules>
</args>
</review>
</routers>
</frontend>
<global>
<helpers>
<dpc_review>
<class>Dpc_Review_Helper</class>
</dpc_review>
<review>
<rewrite>
<data>Dpc_Review_Helper_Data</data>
</rewrite>
</review>
</helpers>
</global>
</config>
ステップ5:アプリ内側:アプリ/コード内部/ローカル/ DPC /レビュー/ヘルパーData.php
と呼ばれるファイル<?php
/**
* Class Dpc_Review_Helper_Data
*/
class Dpc_Review_Helper_Data extends Mage_Review_Helper_Data
{
}
ステップ6を作成します/ code/local/Dpc/Review/controllers/ProductController.phpというファイルを作成します
<?php
require_once 'Mage' . DS . 'Review' . DS . 'controllers' . DS . 'ProductController.php';
/**
* Class Dpc_Review_ProductController
*/
class Dpc_Review_ProductController extends Mage_Review_ProductController
{
/**
* Submit new review action
*
*/
public function postAction()
{
if (!$this->_validateFormKey()) {
// returns to the product item page
$this->_redirectReferer();
return;
}
if ($data = Mage::getSingleton('review/session')->getFormData(true)) {
$rating = array();
if (isset($data['ratings']) && is_array($data['ratings'])) {
$rating = $data['ratings'];
}
} else {
$data = $this->getRequest()->getPost();
$rating = $this->getRequest()->getParam('ratings', array());
}
if (($product = $this->_initProduct()) && !empty($data)) {
$session = Mage::getSingleton('core/session');
/* @var $session Mage_Core_Model_Session */
$review = Mage::getModel('review/review')->setData($data);
/* @var $review Mage_Review_Model_Review */
$validate = $review->validate();
if ($validate === true) {
try {
/****** This is the spot where we are now setting the value to STATUS_APPROVED *******/
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
->setEntityPkValue($product->getId())
->setStatusId(Mage_Review_Model_Review::STATUS_APPROVED)
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
->setStoreId(Mage::app()->getStore()->getId())
->setStores(array(Mage::app()->getStore()->getId()))
->save();
foreach ($rating as $ratingId => $optionId) {
Mage::getModel('rating/rating')
->setRatingId($ratingId)
->setReviewId($review->getId())
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
->addOptionVote($optionId, $product->getId());
}
$review->aggregate();
$session->addSuccess($this->__('Your review has been accepted'));
}
catch (Exception $e) {
$session->setFormData($data);
$session->addError($this->__('Unable to post the review.'));
}
}
else {
$session->setFormData($data);
if (is_array($validate)) {
foreach ($validate as $errorMessage) {
$session->addError($errorMessage);
}
}
else {
$session->addError($this->__('Unable to post the review.'));
}
}
}
// this is my own custom need, feel free to do whatever you want here
$product_url = $product->getUrlPath();
if ($product_url) {
$this->_redirect($product_url);
return;
}
$this->_redirectReferer();
}
}
関連する問題
- 1. Magento:商品フィルタを移動
- 2. facebook自動承認/ログイン
- 3. 商品コードの自動配信ですか?
- 4. Magento:注文商品と設定可能な商品をプログラムで作成
- 5. Magento 100種類の順列の商品を設定する
- 6. スプリングブート全自動設定
- 7. 自動化設定3.2
- 8. アプリ購入商品の承認時間
- 9. 特定の商品の総レビュー数をカウントする
- 10. Maven設定ファイルを自動化する
- 11. 自動認証
- 12. str_replace magento商品名
- 13. Magentoの映画製品の自動記入情報
- 14. 自動スライド機能(Magentoサイト)を作成する間隔を設定します
- 15. プラグイン一Eclipse製品の自動起動
- 16. バンドル商品の動的価格設定JSエラー
- 17. コメントプラグイン内のすべてのコメントを自動承認
- 18. レビューボードで承認されたdiffの自動コミット
- 19. 製品ページのサイドバーに製品のレビューを表示するmagento
- 20. カスタムメール設定を自動的に設定する方法
- 21. マウスの移動時に自動スクロール位置を設定する
- 22. magentoベースの電子商取引サイトで商品を好きなユーザーにギフトカードコードを自動的に提供する方法
- 23. Magento商品カテゴリー別ID
- 24. Magento - 'samples_title'商品属性
- 25. Magento関連商品サイドバー
- 26. 自己ホスト型WCFサービスでのオブジェクトファクトリスコープの自動設定
- 27. ラケットサブクラスでのバインディングの自動継承
- 28. 自動ワークフロー設計
- 29. Magentoの商品レビューサブミットの返品のページ
- 30. 動的商品比較ページ
おかげで –
が、これは、Magentoの1.7上で動作します取り組んでいます をWebFlakeStudio?私は1.7バージョンを使用しているので。それは動作していません。私は他のアプローチを提案できますか? –
@ジョン - そのリンクのために、私はReviewカスタムモジュールをAutoreviewに改名しました。それは私のために働きました。私はMagento 1.8を使用しています。 –