2012-01-30 3 views
4

Magento 커뮤니티 에디션 1.4의 인덱스 관리에서 사용자 지정 인덱서를 만들려고하는데,이 사용자 지정 인덱서의 주된 목적은 일련의 계산을 기반으로 사용자 지정 제품 특성을 업데이트하는 것입니다.Magento CE 1.4 인덱서 - 인덱스 관리

나는 마젠토 핵심 코드를 조사하고 필요한 것과 비슷한 것을 만들었지 만 주제에 대한 충분한 문서를 찾을 수 없었습니다.

내가 지금까지 가지고이 : 나는 나의 새로운 사용자 정의 인덱서를 볼 수 있었다이 코드를 실행 한 후 모델

class MyModule_Custom_Model_Indexer_Price extends Mage_Index_Model_Indexer_Abstract 
{ 
protected $_matchedEntities = array(
    Mage_Catalog_Model_Product::ENTITY => array(
     Mage_Index_Model_Event::TYPE_SAVE, 
     Mage_Index_Model_Event::TYPE_DELETE, 
     Mage_Index_Model_Event::TYPE_MASS_ACTION 
    ) 
); 

/** 
* Initialize resource model 
* 
*/ 
protected function _construct() 
{ 
    $this->_init('custome/indexer_price'); 
} 

public function getName() 
{ 
    return Mage::helper('customizer')->__('Customizable Products'); 
} 

public function getDescription() 
{ 
    return Mage::helper('customizer')->__('Index Customizable Product Prices'); 
} 

public function matchEvent(Mage_Index_Model_Event $event) { 
    Mage::log("Should I match an event: ".$event->getEntity() . '|'. $event->getType()); 
    return true; 
} 

protected function _registerEvent(Mage_Index_Model_Event $event) { 
    Mage::log("Should I register an event: ".$event->getEntity() . '|'. $event->getType()); 
} 

protected function _processEvent(Mage_Index_Model_Event $event) { 
    Mage::log("Should I process an event: ".$event->getEntity() . '|'. $event->getType()); 
} 

public function reindexAll() { 

    Mage::log('Do my processing to reindex'); 
} 
} 

을 만들어

config.xml에

<?xml version="1.0"?> 
<config> 
<!-- configuration --> 
    <global> 
     <index> 
      <indexer> 
       <custom_product_price> 
       <model>custom/indexer_price</model> 
       </custom_product_price> 
      </indexer> 
     </index> 
    </global> 
<!-- configuration --> 
</config> 

을 다음 색인 관리 그리드에서 항목을 선택했지만 reindex 작업을 실행했을 때 reindexAll() 메서드가 방금 발생했습니다.

어떤 아이디어라도 도움이 될 수 있으며 미리 감사드립니다.

+0

실제로 여기에서 무엇을 묻고 있는지 확실하지 않은가요? – edmondscommerce

답변

2

올바른 Magento 동작입니다. 여기에 대한 설명은 다음과 같습니다

 
Mage::getSingleton('index/indexer')->processEntityAction($this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE); 

: 이 제품은 저장 한 후

, 색인화은 다음 호출에 Mage_Catalog_Model_Product :: afterCommitCallback()에 트리거 (코드 예는 1.4.0.0이 젠토 가전에서 촬영) processEntityAction을 살펴보면 인덱스가 일치하고 인덱스 모드가 "수동"이 아닌 경우 magento가 인덱서 모델의 _processEvent 메소드를 실행한다는 것을 알 수 있습니다. Magento는 Magento가 실행을 마치면 "index_process_event"테이블에서 보류중인 항목을 삭제합니다.

관리자 패널에서 다시 색인을 실행하면 Magento는 "index_process_event"테이블에 색인에 대한 보류중인 항목이 있는지 확인합니다. 예를 들어 Magento는 모델의 _processEvent 메소드를 실행하고 그렇지 않으면 reindexAll을 실행합니다. 따라서, magento가 reindexAll을 실행하는 것은 완전히 올바른 것입니다. Magento가 reindexAll 대신 _processEvent를 실행하게하려면 관리 패널을 통해 인덱스 모드를 "수동"으로 변경해야합니다.