Classification code-product classification!

Source: Internet
Author: User

<? PHP
02 $ c = Mage: GetModel ('catalog/Category ');

// Obtain a model set based on the attributes.
03 $ Pc = $ C-> loadbyattribute ('name', 'buy gift box ');
04 if ($ PC-> haschildren ()){
05 $ IDs = $ PC-> getchildren ();

// Obtain the classification set of all products.
06 $ subcategories = Mage: GetModel ('catalog/Category ')-> getcollection ();

// Use the getselect () method and the where () method to reselect.
07 $ subcategories-> getselect ()-> where ("e. entity_id in ($ IDs )");
08 $ subcategories-> addattributetoselect ('*');
09 $ subcategories-> load ();
10}
11?>

 

 

 

 

 

 

The label <cms_page_read> in layout is the layout handle loaded when weburl/CMS/page/read is the access path. layout is the default one !! So powerful, let me come up with it tonight !!
!

// Load the cache.
$ This-> loadlayout ();
// Obtain the block instance.
$ Block = Mage: getblocksingleton ('profile/profile ');
// Load Profile
// $ Block-> getprofile () ---------- return a collection of profiles.
$ Profile = $ block-> getprofile ();
If ($ profile ){
// Operate the parameters in layout (using methods), so it is flexible !!
$ This-> getlayout ()-> getblock ('head')-> settitle ($ profile-> getdata ("content_heading "))
-> Setdescription ($ profile-> getdata ("meta_description "))
-> Setkeywords ($ profile-> getdata ("meta_keywords "));
}
// Draw it out !!
$ This-> renderlayout ();

// Return a collection of profiles.

Public Function getprofiles ($ category_id ){
$ Profiles = Mage: GetModel ('profile/profile ')-> getcollection ()
// The following is a detailed study !!
-> Addstorefilter (Mage: APP ()-> getstore ()-> GETID ());
$ Profiles-> addfieldtofilter ('category _ id', $ category_id );
$ Profiles-> setorder ("creation_time", "DESC ");
Return $ profiles;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.