Sunday, March 18, 2012

magento常用的语句


1.
得到产品,以及过滤:
getResourceModel('catalog/product_collection')
$collection = Mage::getModel('catalog/product')->getCollection();
->Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
2.
    public function addAttributeToSelect($attribute, $joinType = false)
   

取得属性集,属性过滤
   $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'));
实体的 不能是布尔的

2 comments:

  1. Enquire well in regards to the statistical actions & the children will surely appreciate it. There are many different ways to encourage children to be able that they really like studying the essential ideas of statistical. Today's studying program is not the best for the children. They need perfect statistical actions for their education.

    Buy WOW Gold  RS Gold  Buy Diablo 3 Gold

    ReplyDelete