2016-12-13 13 views
2

私は、magentoで呼び出されていない、urlのコントローラの別のメソッドexeptインデックスを呼び出そうとしています。どのように私はURLのコントローラの他のメソッドを呼び出すことができます。私の敗北はある。 localhost/sewingapis/categories/index/testingメソッドを使用します。Magentoコントローラメソッドが呼び出されていない

私のコントローラのコードは次のとおりです。

class Product_Category_IndexController extends Mage_Core_Controller_Front_Action 
    { 
     public function indexAction() 
     { 

      $parent = Mage::app()->getStore()->getRootCategoryId();  
      $tree = Mage::getResourceModel('catalog/category_tree'); 
      /* @var $tree Mage_Catalog_Model_Resource_Category_Tree */ 

      $nodes = $tree->loadNode($parent) 
       ->loadChildren($recursionLevel) 
       ->getChildren(); 
      $tree->addCollectionData(null, false, $parent); 

      $categoryTreeData = array(); 
      foreach ($nodes as $node) { 
       $categoryTreeData[$node->getData('entity_id')] = $this->getNodeChildrenData($node); 
      } 

      //return $categoryTreeData; 
      $response['status'] = true; 
      $response['data'] = $categoryTreeData; 
      echo json_encode($response); 

     } 

     function getNodeChildrenData(Varien_Data_Tree_Node $node) 
     { 
      $data = array(
       'title' => $node->getData('name'), 
       'url' => $node->getData('url_key'), 
      ); 

      foreach ($node->getChildren() as $childNode) { 
       if (!array_key_exists('children', $data)) { 
        $data['children'] = array(); 
       } 

       $data['children'][$childNode->getData('entity_id')] = $this->getNodeChildrenData($childNode); 
      } 
      return $data; 
     } 

     public function getCatSubCatByProductId() 
     { 
      $categoryId = 10;  
      $products = Mage::getSingleton('catalog/category')->load($categoryId) 
        ->getProductCollection() 
        ->addAttributeToSelect('*'); 
      } 

      public function testingMethod(){ 
      echo 'hello'; 
      } 
    } 

マイconfig.xmlに。

<config>  
    <modules> 
     <Product_Category> 
      <version>0.1.0</version> 
     </Product_Category> 
    </modules> 
    <frontend> 
     <routers> 
      <category> 
       <use>standard</use> 
       <args> 
        <module>Product_Category</module> 
        <frontName>categories</frontName> 
       </args> 
      </category> 
     </routers> 
    </frontend> 

</config> 

答えて

1

Actionの添字は、indexアクションに追加されたものと同じメソッド名に追加する必要があります。

public function testingMethodAction(){ 
     echo 'hello'; 
} 
+0

私の解決した問題です。 Pankaj Pareekに感謝します。 –

関連する問題