Magento模块块不起作用以及如何使用观察器


magento module block not working and how to use observer

我是magento模块开发的新手,目前我正在开发一个模块,但我被困在一行中,我也想学习观察者,但每次我都失败了。目前我想获取所有产品列表,但没有结果也没有错误。有什么帮助吗?

这是我的尝试

: 应用程序/等/模块/Abc_Mymodule.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Abc_Mymodule>
    <active>true</active>
    <codePool>local</codePool>
    </Abc_Mymodule>
  </modules>
</config>  

我的配置文件在app/code/local/Abc/Mymodule/etc/config中.xml

 <?xml version="1.0"?>
 <config>
<modules>
    <Abc_Mymodule>
        <version>0.4.0</version>    <!-- Version number of your module -->
    </Abc_Mymodule>
</modules>
 <global>
    <models>
        <catalog>
            <rewrite>
                <product_type>Abc_Mymodule_Model_Product_Type</product_type>
            </rewrite>
        </catalog>  
      <Mymodule>
           <class>Abc_Mymodule_Model</class>
            <resourceModel>Mymodule_Mysql4</resourceModel>
      </Mymodule>
    </models>
    <resources>
        <Mymodule_setup>
            <setup>
                <module>Abc_Mymodule</module>
                <class>Abc_Mymodule_Model_Resource_Setup</class>
            </setup>                
        </Mymodule_setup>            
    </resources>
    <blocks>
        <Mymodule>
            <class>Abc_Mymodule_Block</class>
        </Mymodule>
    </blocks>
</global>       
<frontend>
    <routers>
        <mymodule>
            <use>standard</use>
            <args>
                <module>Abc_Mymodule</module>
                <frontName>Mymodule</frontName>
            </args>
        </mymodule>
    </routers>
    <layout>
        <updates>
            <Mymodule>
                <file>Mymodule.xml</file>
            </Mymodule>
        </updates>
    </layout>
</frontend>
</config>

我的控制器是app/code/local/abc/Mymodule/controllers/PpController.php

<?php
class Abc_Mymodule_PpController extends Mage_Core_Controller_Front_Action
{
 public function productlistAction(){
 /*
     $block = $this->getLayout()->createBlock('Mymodule/Productlist');
    $cole1 =         $block->getCollection();    
     print_r($cole1);
 die;*/
    $this->loadLayout();     
    $this->renderLayout();
 }
 public function postcategoryAction(){
  $userid = Mage::getSingleton('customer/session')->getCustomer()->getId();  
  $parentId = '64';
  $title = $this->getRequest()->getPost('category_name');
   $url=$this->getRequest()->getPost('category_url');
 try{
$category = Mage::getModel('catalog/category');
$category->setName($title);
$category->setUrlKey($url);
$category->setcuid($userid);
$category->setIsActive(0);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(0); //for active achor
$category->setStoreId(Mage::app()->getStore()->getId());
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
$category->setPath($parentCategory->getPath());
$category->save();
    } catch(Exception $e) {
        var_dump($e);
    }
 Mage::getSingleton('core/session')->addSuccess('Category has been successfully added');

 $this->_redirect('customer/account');
 }
 public function categorylistAction(){
     $this->loadLayout();     
    $this->renderLayout();
 }

?>

我的块是应用程序/代码/本地/Abc/Mymodule/块

<?php
class Abc_Mymodule_Block_Productlist extends Mage_Core_Block_Template
{
private $cuserid = null;
private $store_id = null;
protected function _construct()
{
//          $cat33 = $this->getCurrentCategory();
$this->store_id = Mage::app()->getStore()->getId();
  //parent::__construct();
$this->cuserid  = Mage::getSingleton('customer/session')->getCustomer()->getId();

    $collection = Mage::getModel('catalog/product')->getCollection();
  /*$collection =   Mage::getModel('catalog/product')
                    ->getCollection()
        ->addAttributeToSelect('*')
                    ->addAttributeToFilter('mmuserid', array('eq' => $this->cuserid))
                    ->load();*/
    $this->setCollection($collection);
  }
?>

我想使用事件可以对观察者或事件有任何帮助吗?

这是我的模数

<?xml version="1.0"?>
<layout version="0.1.0">
<mymodule_pp_product>
<reference name="root">
        <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        <action method="addBodyClass"><class>customer-account</class></action>
    </reference>
<reference name="content" >
      <block type="Mymodule/Productadd"  name="productadd"  template="mymodule/productadd.phtml"  />
</reference>
 <reference name="left">
        <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
            <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
            <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
            <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
        </block>
    </reference>
    </mymodule_pp_product>
     </layout>
好吧,

实际上没有答案,我知道块不起作用的原因有一个小的拼写错误,现在我已经编辑了我的问题并且现在拼写正确并为我工作。