Fun with Flags: //easy shortcut :) $MatchedDate = ""; /*empty string Flag*/ foreach ($catalogrules as $Crule) {/*if a date matches set $MatchedDate name to _sale*/ if ($Crule->getIsActive() && $today >= strtotime($Crule["from_date"]) && $today <= strtotime($Crule["to_date"])) { $MatchedDate = "_sale";/*set the flage to somestring*/ break; } } getLayout()->createBlock('cms/block')->setBlockId('customer_top_section' . $MatchedDate)->toHtml() ; /*flag is blank until filled*/ }else{ echo $this->getLayout()->createBlock('cms/block')->setBlockId('customer_top_section_shop_by' . $MatchedDate)->toHtml() ;/*flag is blank until filled*/ } ?> /*******************************************************************************/ //This checks to see if the page is comming from http or https to change the block on the search tool or the home page and the Register / Login link below -- by Grace if (empty($_SERVER['HTTPS'])){ //if it's empty make the url without the s:// $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; } else { $url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; } if (strpos($_SERVER['REQUEST_URI'],'max_search_tool')) { echo "
New clear url for max tool:
" . Mage::getBaseUrl(). "max_search_tool?cat=" . $prevPath; } else { echo '
Not on the max_search_tool page.'; /*******************************************************************************/ $object->property, $object->method() /*******************************************************************************/ echo get_parent_class ($this); /*******************************************************************************/ $z = get_class_methods($DB);// these are the member functions of that object echo "
"; var_export($z); echo "
"; //jackpot! USE THIS OFTEN!!!!!!! /*******************************************************************************/ $z = get_class_vars($_filter); echo "
"; var_dump($z); echo "
"; /*******************************************************************************/ $z = get_object_vars($_filter); echo "
"; var_dump($z); echo "
"; /*******************************************************************************/ echo " t " ; echo "
"; var_export(get_class_methods($_filter)); echo "
"; echo"
";echo"
"; echo implode(',',get_class_methods(Mage::getModel('catalog/category')->load(3))); echos lots of stuff!!! array(155) { [0]=> string(4) "init" [1]=> string(14) "_prepareFilter" [2]=> string(19) "_prepareFilterBlock" [3]=> string(9) "getFilter" [4]=> string(7) "getName" [5]=> string(20) "getSelectedSeoValues" [6]=> string(17) "getPopupBlockName" [7]=> string(13) "getItemsCount" [8]=> string(25) ?> /*******************************************************************************/ root@box [~]# curl http://box.com/index.php/?cat=5 > filters % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 93.0M 0 93.0M 0 0 19.7M 0 --:--:-- 0:00:04 --:--:-- 25.0M root@box [~]# less filters /*******************************************************************************/ public function getAllChildren($asArray = false) /*******************************************************************************/ echo "
type is " . gettype(Mage::getModel('catalog/category')->load($catid)->getAllChildren($asArray = true)); echo "
strlen is " . strlen(Mage::getModel('catalog/category')->load($catid)->getAllChildren($asArray = true)); /*******************************************************************************/ 'bar', 'property' => 'value'); echo $obj->foo; // prints 'bar' echo $obj->property; // prints 'value' ?> allows you to access a method or value within an object, the same way that [] allows you to access values within an array. // A class is like a box, and within that box there is a lot of items, and each item can interact with each other as they are within the same box. // For example: // class Box // { // function firstItem() // { // } // // function secondItem() // { // } // } // The above is what we call a class. It's basically a structured piece of code that does not really do anything until it becomes an object. // The object is created by using the new keyword, which instantiates a class and creates an objects from it. // $box = new Box; // this is making an instance of the object of that class // Now the above $box, which is an object created from the Box class, has methods inside, such as firstItem(). // These are just like functions apart from within them we have another variable called $this and this is used to access other methods within that object. // Now to access the methods from outside the objects you have to use the operator described in your question. // $box->firstItem(); // The operator -> will allow you to execute the method from the variable $box. // *********************************************************************** class Animal implements Singable{ // This is a SUPER class, this is only assigning animal attributes and describing what they are have //can have public(any code can access), private(only methods or functions can access), or protected( like private, but subclasses can still access) protected $name; //this is an attribute protected $favorite_food; protected $sound; protected $id; public static $number_of_animals = 0; //static means any object of the type animal that is created shares this attribute. //to access this type: Animal::$number_of_animals const PI = "3.14159"; // constant means this never changes it's value. //to access this type: Animal::PI function getName(){ return $this->name; //known as encapsulating the data... it allows you to call getName() to access the protected attribute $name //$this in this case is referring to THIS specific class } //anything with a __ in front is called a magic method, these are used for setting and getting data. function __construct(){ //this initializes everything $this->id = rand(100, 10000); echo $this->id . "has been assigned"; Animal::$number_of_animals++; } public function __destruct(){//called when all references to an object have been unset echo $this->name . " is being destroyed"; //'name' here means the variable above^ protected $name; } function __get($name){ //gets values echo "Asked for " . $name . "
"; return $this->$name; //'name' here means the variable that was passed in the argument __get($name) } function __set($name, $value){ //sets values switch($name){ case "name" : $this->name = $value; break; case "favorite_food" : $this->favorite_food = $value; break; case "sound" : $this->sound = $value; break; default : echo $name . " Not Found"; } echo "Set " . $name . " to " . $value . "
"; } function run(){ echo $this->name . " runs "; } final function what_is_good(){ //final can not be overridden in a subclass echo "Running is good"; } function __toString(){ return echo $this->name . " says " . $this->sound . " give me some " . $this->favorite_food . " my id is " . $this->id . " total animals = " . Animal::$number_of_animals . "Favorite Numer " . Animal::PI; } function sing(){//any class that implements an interface must define the functions that are inside of the interface. echo $this->name . " sings 'Woof woof'"; } static function add_these($num1, $num2){ return ($num1 + $num2) } } class Dog extends Animal implements Singable{ //this is a subclass...means that Dog will inherit all of the properties of the superclass animal and can access anything set to "protected". implements means that it must define the function inside the Singable interface below. //this method "overrides the method in the run function of the superclass function run(){ echo $this->name . " run like crazy "; //Dog can access "name" since it was set to protected } function sing(){//any class that implements an interface must define the functions that are inside of the interface. echo $this->name . " sings 'Grr grr grr'"; } } interface Singable{//any class that implements an interface must define the functions that are inside of the interface. This is polymorphism public function sing(); } $animal_one = new Animal(); //This is creating an animal object that has the attibutes from the animal class //creating an object is also known as instantiating //the __construct() is called whenever a new Animal() is created $animal_one->name = "Spot"; $animal_one->favorite_food = "Meat"; $animal_one->sound = "Ruff"; echo $animal_one->name . " says " . $animal_one->sound . " give me some " . $animal_one->favorite_food . " my id is " . $animal_one->id . " total animals = " . Animal::$number_of_animals . "Favorite Numer " . Animal::PI; $animal_clone = clone $animal_one; //creates a copy of the animal_one object $animal_two = new Dog(); //This is creating an animal object that has the attibutes from the animal class since Dog extends animal //creating an object is also known as instantiating //the __construct() is called whenever a new Animal() is created $animal_two->name = "HazelNut"; $animal_two->favorite_food = "Cheese"; $animal_two->sound = "Boof"; echo $animal_two->name . " says " . $animal_two->sound . " give me some " . $animal_two->favorite_food . " my id is " . $animal_two->id . " total animals = " . Dog::$number_of_animals . /*Dog:: works because the dog class is extended to the animal class.*/ "Favorite Numer " . Animal::PI; function make_them_sing(Singable $singing_animal){ $singing_animal-sing(); } function sing_animal(Animal $singing_animal){ $singing_animal-sing(); } //these are both accessing the run function and would display Spot runs and HazelNut runs like crazy, then both would be destroyed. $animal_one->run(); $animal_two->run(); $animal_two->what_is_good(); //this is accessing the what_is_good function and would display Running is good and then be destroyed. $animal_one->sing(); //echo's Spot sings Woof woof make_them_sing($animal_one); //outputs Spot sings Woof woof make_them_sing($animal_two); //outputs HazelNut sings Grr grr grr sing_animal($animal_one); //outputs Spot sings Woof woof sing_animal($animal_two); //outputs HazelNut sings Grr grr grr echo "3+5= " . Animal::add_these(3,5); //echo's 3+5=8 //********to check if it's a class type********* $is_it_an_animal = ($animal_two instanceof Animal) ? "True" : "False"; echo "It is " . $is_it_an_animal . ' that $animal_two is an Animal'; // echo's It is True that $animal_two is an Animal //Magento Example load(3); ******************************************************************** ******************************************************************** $category=Mage:://Mage should be a class //Can't fing any references to only Mage, all are Mage_ ******************************************************************** ******************************************************************** $category=Mage::getModel()//getModel is a static or constant function //app/code/local/ManaPro1/FilterAdmin/Block/Card/General.php: public function getModel() { public function getModel() { return Mage::registry('m_crud_model'); //??? what the hell is registry()???? } ******************************************************************** //app/code/local/Mana1/Db/Helper/Formula/Selector.php: registry() * frontend entity example: catalog/category for mana_attributepage/page (in database there is no relation to * frontend entity, but it is known when calculated in frontend, typically from Mage::registry()). Such entities * are left unprocessed (with type = 'formula,int' or 'formula,string') and are only processed before displaying * data in frontend. Frontend entities can appear in identifier chain in first position only. ******************************************************************** ******************************************************************** ******************************************************************** $category=Mage::getModel('catalog/category' // 'catalog/category is $this->setData(array('Categories' => $res->exportCategories(), ******************************************************************** ******************************************************************** $category=Mage::getModel('catalog/category')->load(); //->load() should be a function inside of getModel??? //function load() is everywhere.... app/code/core/Mage/Catalog/Model/Convert/Adapter/Catalog.php best guess public function load() { $res = $this->getResource(); //getResource is everywhere...app/code/local/Mana/Filters/Helper/Item.php: public function getResource() { ******************************************************************** public function getResources() { if (!$this->_resources) { $this->_resources = array(); foreach ($this->coreHelper()->getSortedXmlChildren(Mage::getConfig()->getNode('mana_filters/item_repository'), 'resources') as $key => $xml) { $this->_resources[$key] = Mage::getResourceSingleton((string)$xml->resource); if (!($this->_resources[$key] instanceof Mana_Filters_Resource_ItemAdditionalInfo)) { throw new Exception(sprintf('%1 must be instance of %2', get_class($this->_resources[$key]), 'Mana_Filters_Resource_ItemAdditionalInfo')); } } } return $this->_resources; } ******************************************************************** $this->setData(array( 'Products' => $res->exportProducts(), 'Categories' => $res->exportCategories(), ******************************************************************** // app/code/core/Mage/Dataflow/Model/Mysql4/Catalogold.php: public function exportCategories() public function exportCategories() { $collection = Mage::getResourceModel('catalog/category_collection') ->addAttributeToSelect('*') ******************************************************************** //app/code/core/Mage/Catalog/Model/Resource/Category/Flat/Collection.php: public function addAttributeToSelect($attribute = '*') //app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php: public function addAttributeToSelect($attribute, $joinType = false) //app/code/core/Mage/Sales/Model/Resource/Collection/Abstract.php: public function addAttributeToSelect($attribute) //app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php: public function addAttributeToSelect($attribute, $joinType = false) public function addAttributeToSelect($attribute, $joinType = false) { if ($this->isEnabledFlat()) { if (!is_array($attribute)) { $attribute = array($attribute); } foreach ($attribute as $attributeCode) { if ($attributeCode == '*') { foreach ($this->getEntity()->getAllTableColumns() as $column) { $this->getSelect()->columns('e.' . $column); $this->_selectAttributes[$column] = $column; $this->_staticFields[$column] = $column; } } else { $columns = $this->getEntity()->getAttributeForSelect($attributeCode); if ($columns) { foreach ($columns as $alias => $column) { $this->getSelect()->columns(array($alias => 'e.' . $column)); $this->_selectAttributes[$column] = $column; $this->_staticFields[$column] = $column; } } } } return $this; } return parent::addAttributeToSelect($attribute, $joinType); } ******************************************************************** ->load(); $categories = array(); foreach ($collection as $object) { $row = $object->getData(); $categories[] = $row; } return $categories; } ******************************************************************** 'Image Gallery' => $res->exportImageGallery(), 'Product Links' => $res->exportProductLinks(), 'Products in Categories' => $res->exportProductsInCategories(), 'Products in Stores' => $res->exportProductsInStores(), 'Attributes' => $res->exportAttributes(), 'Attribute Sets' => $res->exportAttributeSets(), 'Attribute Options' => $res->exportAttributeOptions(), )); return $this; } ******************************************************************** $category=Mage::getModel('catalog/category')->load(3);// 3 is the argument for load??? ******************************************************************** ******************************************************************** $children = explode( "," , $category->getChildren()); //this is print_r of children : Array ( [0] => 5 [1] => 8 ) //app/code/core/Mage/Catalog/Model/Category.php: public function getChildren() ******************************************************************** ******************************************************************** public function getChildren() { return implode(',', $this->getResource()->getChildren($this, false)); //which $this is that????? } ******************************************************************** // public function getChildrenCategories() // { // return $this->getResource()->getChildrenCategories($this); // } $children = explode( "," , $category->getChildrenCategories()); public function getAllChildren($asArray = false) ?>