카테고리 ID를 부여하고 결과가 JSON 형식이어야 할 때 제품의 등급 (마젠타 색)을 얻고 싶습니다. 브라우저 페이지에서 JSON 데이터를 얻고 싶습니다.이 앱에 대한 Rating.php를 확장했습니다. 코드/코어/마법사/등급/모델/Rating.php확장 평가 기능을 실행하기위한 URL은 무엇입니까
인치 사이트에 따르면, 방금 모델 파일을 복사하여 app/code/local/mynamespace/appname/Model/Rating.php에 붙여 넣었습니다. config.xml 파일을 app/code/local/mynamespace/appname/etc/config.xml에 작성하고 app/etc/modules에 xml을 작성했습니다.
사이트에서 그들은 'var_dump (get_class ($ this)); 출구();' 필요한 기능에서. 하지만이 등급을 얻을 수있는 URL을 여러 가지 방법으로, 그러나 아무 소용이 시도 ... 파일은 folows과 같습니다
Rating.php 응용 프로그램/코드/지역/MyNamespace에에서
<?php
class mnamespace_appname_Model_Rating extends Mage_Core_Model_Abstract
{
/**
* rating entity codes
*
*/
const ENTITY_PRODUCT_CODE = 'product';
const ENTITY_PRODUCT_REVIEW_CODE = 'product_review';
const ENTITY_REVIEW_CODE = 'review';
/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('rating/rating');
}
public function addOptionVote($optionId, $entityPkValue)
{
Mage::getModel('rating/rating_option')->setOptionId($optionId)
->setRatingId($this->getId())
->setReviewId($this->getReviewId())
->setEntityPkValue($entityPkValue)
->addVote();
return $this;
}
public function updateOptionVote($optionId)
{
Mage::getModel('rating/rating_option')->setOptionId($optionId)
->setVoteId($this->getVoteId())
->setReviewId($this->getReviewId())
->setDoUpdate(1)
->addVote();
return $this;
}
/**
* retrieve rating options
*
* @return array
*/
public function getOptions()
{
if ($options = $this->getData('options')) {
return $options;
}
elseif ($id = $this->getId()) {
return Mage::getResourceModel('rating/rating_option_collection')
->addRatingFilter($id)
->setPositionOrder()
->load()
->getItems();
}
return array();
}
public function getEntitySummary($entityPkValue, $onlyForCurrentStore = true)
{
$this->setEntityPkValue($entityPkValue);
return $this->_getResource()->getEntitySummary($this, $onlyForCurrentStore);
}
public function getReviewSummary($reviewId, $onlyForCurrentStore = true)
{
$this->setReviewId($reviewId);
return json_encode($this->_getResource()->getReviewSummary($this, $onlyForCurrentStore));
var_dump(get_class($this)); //these are the lines added specially
exit(); //these two lines(upline also)
}
/**
* Get rating entity type id by code
*
* @param string $entityCode
* @return int
*/
public function getEntityIdByCode($entityCode)
{
return $this->getResource()->getEntityIdByCode($entityCode);
}
}
config.xml 파일 관리자 패널에서/Mynamespace_Appname.xml
<?xml version="1.0"?>
<config>
<modules>
<Mynamespace_Appname>
<active>true</active>
<codePool>local</codePool>
</Mynamespace_Appname>
</modules>
</config>
응용 프로그램은/etc/modules에
<?xml version="1.0"?>
<config>
<modules>
<Mynamespace_Appname>
<version>0.1</version>
</Mynamespace_Appname>
</modules>
<global>
<models>
<Appname>
<rewrite>
<item>Mynamespace_Appname_Model_Rating</item>
</rewrite>
</Appname>
</models>
</global>
</config>
파일 /Appname/etc/cnfig.xml 그것은 활성화 된 모듈을 보여줍니다. 그러나 모델 파일을 실행하기위한 올바른 URL을 찾지 못했습니다 .. 이 파일을 보려면보기 파일을 만들어야합니까 ???
사람이 ...이 ...이에 오류가있는 경우를 언급 해주십시오에 사전에
감사 나를 도울 수
죄송합니다 .. 주 파일에서 올바른 것입니다. URL에 제품 ID 만 제공하여 위의 등급 모델을 쿼리하는 url을 말할 수 있습니까? –