お客様が商品に関するレビューを投稿すると、レビューは自動的に承認される必要があります。管理者によって承認される必要はありません。商品レビューを自動設定する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. WooCommerce - 自宅で商品を自動追加または自動削除する
- 3. Magento 2:商品レビューを保存
- 4. Magento:商品フィルタを移動
- 5. facebook自動承認/ログイン
- 6. Woocommerce:ユーザーのメタで商品を自動的に商品に追加
- 7. 独自の自動設定
- 8. PHPによる自動承認リンク
- 9. 店舗の商品を自動的に追加する方法
- 10. Magento:注文商品と設定可能な商品をプログラムで作成
- 11. 商品コードの自動配信ですか?
- 12. 自動レイアウト設定
- 13. Wordpressのコメントは、ユーザーの自動承認
- 14. 承認番号の自動承認付きのGoogleログインボタン
- 15. WooCommerce - 自動的にボーナス商品を追加
- 16. 商品を削除した後の自動URL書き換え
- 17. Magento 100種類の順列の商品を設定する
- 18. Magentoの製品ページのレビュー
- 19. Magento 1.9 urlでカートに設定可能な商品を追加
- 20. バーチャルおよびダウンロード可能な商品設定を自動的に有効にする
- 21. woocommerceの注文に自動的に商品を(バックハンドで)追加するには?
- 22. haskell自動テスト設定
- 23. 自動.gitlab-ci.yml lftp設定
- 24. スプリングブート全自動設定
- 25. Azureテーブルパーティションキー自動設定?
- 26. pycharm自動インデント設定
- 27. スプリングブート有界自動設定
- 28. 自動化設定3.2
- 29. 自動保存設定アンドロイドスタジオ
- 30. NPM自動設定スクリプト
おかげで –
が、これは、Magentoの1.7上で動作します取り組んでいます をWebFlakeStudio?私は1.7バージョンを使用しているので。それは動作していません。私は他のアプローチを提案できますか? –
@ジョン - そのリンクのために、私はReviewカスタムモジュールをAutoreviewに改名しました。それは私のために働きました。私はMagento 1.8を使用しています。 –