1. 得到产品,以及过滤:
getResourceModel('catalog/product_collection') $collection = Mage::getModel('catalog/product')->getCollection(); ->Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
2.取得属性集,属性过滤
$attributes = Mage::getSingleton('catalog/config') ->getProductAttributes(); $collection->addAttributeToSelect($attributes) //选择属性 ->addMinimalPrice() ->addFinalPrice() ->addTaxPercents() ->addAttributeToFilter('test_product', 1, 'left') //属性过滤 具备该属性 ->addStoreFilter(); //商店过滤 Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); //对产品的状态进行可见性过滤 Disable,EnableMage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); //visibility过滤 Catalog,Search,Not Visible$this->_productCollection = $collection;
3.
protected function _prepareLayout() //面包屑 { if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) { $breadcrumbsBlock->addCrumb('home', array( 'label'=>Mage::helper('catalog')->__('Home'), 'title'=>Mage::helper('catalog')->__('Go to Home Page'), 'link'=>Mage::getBaseUrl() )); } parent::_prepareLayout(); }
4.
protected function _beforeToHtml() { parent::_beforeToHtml(); $toolbar = $this->getToolbarBlock(); //工具条 $toolbar->removeOrderFromAvailableOrders('position'); //移除可用的排序 return $this; }
5. 设定使用的模板
$this->setTemplate('catalog/product/edit.phtml'); //设置模板
6. 后台修改加入后台的块内容
$this->_addContent($this->getLayout()->createBlock('test/adminhtml_catalog_product_edit')); //实体的 不能是布尔的
7.图片的在php文件调用
<img src="<?php echo $this->getSkinUrl('images/tweeticon.jpg');?>"/>
8. 得到当前的store的RootCategoryId
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
9. 得到catelog
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
10.
$collection = Mage::getResourceModel('catalog/product_collection') ->setStoreId($this->getStoreId()) ->addCategoryFilter($this);