Magento Category Object Methods

I was just debugging a Magento problem and thought I would list out all the available methods for the category objects I was working through. Quite handy to have as a reference I thought, so here they are.


Mage_Catalog_Model_Category

  • getUrlInstance()
  • getUrlRewrite()
  • getTreeModel()
  • getTreeModelInstance()
  • move(parentId,afterCategoryId)
  • getDefaultAttributeSetId()
  • getProductCollection()
  • getAttributes(noDesignAttributes)
  • getProductsPosition()
  • getStoreIds()
  • getLayoutUpdateHandle()
  • getStoreId()
  • setStoreId(storeId)
  • getUrl()
  • getUrlModel()
  • getCategoryIdUrl()
  • formatUrlKey(str)
  • getImageUrl()
  • getUrlPath()
  • getParentCategory()
  • getParentId()
  • getParentIds()
  • getCustomDesignDate()
  • getDesignAttributes()
  • getAllChildren(asArray)
  • getChildren()
  • getPathInStore()
  • checkId(id)
  • getPathIds()
  • getLevel()
  • verifyIds(ids)
  • hasChildren()
  • getRequestPath()
  • getName()
  • getAnchorsAbove()
  • getProductCount()
  • getCategories(parent,recursionLevel,sorted,asCollection,toLoad)
  • getParentCategories()
  • getChildrenCategories()
  • getChildrenCategoriesWithInactive()
  • getParentDesignCategory()
  • isInRootCategoryList()
  • getAvailableSortBy()
  • getAvailableSortByOptions()
  • getDefaultSortBy()
  • validate()
  • afterCommitCallback()
  • lockAttribute(attributeCode)
  • unlockAttribute(attributeCode)
  • unlockAttributes()
  • getLockedAttributes()
  • hasLockedAttributes()
  • isLockedAttribute(attributeCode)
  • setData(key,value)
  • unsetData(key)
  • getResourceCollection()
  • loadByAttribute(attribute,value,additionalAttributes)
  • getStore()
  • getWebsiteStoreIds()
  • setAttributeDefaultValue(attributeCode,value)
  • getAttributeDefaultValue(attributeCode)
  • setExistsStoreValueFlag(attributeCode)
  • getExistsStoreValueFlag(attributeCode)
  • isDeleteable()
  • setIsDeleteable(value)
  • isReadonly()
  • setIsReadonly(value)
  • getIdFieldName()
  • getId()
  • setId(id)
  • getResourceName()
  • getCollection()
  • load(id,field)
  • afterLoad()
  • save()
  • isObjectNew(flag)
  • getCacheTags()
  • getCacheIdTags()
  • cleanModelCache()
  • delete()
  • getResource()
  • getEntityId()
  • clearInstance()
  • __construct()
  • _addFullNames()
  • _initOldFieldsMap()
  • _prepareSyncFieldsMap()
  • isDeleted(isDeleted)
  • hasDataChanges()
  • setIdFieldName(name)
  • addData(arr)
  • unsetOldData(key)
  • getData(key,index)
  • _getData(key)
  • setDataUsingMethod(key,args)
  • getDataUsingMethod(key,args)
  • getDataSetDefault(key,default)
  • hasData(key)
  • __toArray(arrAttributes)
  • toArray(arrAttributes)
  • _prepareArray(arr,elements)
  • __toXml(arrAttributes,rootName,addOpenTag,addCdata)
  • toXml(arrAttributes,rootName,addOpenTag,addCdata)
  • __toJson(arrAttributes)
  • toJson(arrAttributes)
  • toString(format)
  • __call(method,args)
  • __get(var)
  • __set(var,value)
  • isEmpty()
  • _underscore(name)
  • _camelize(name)
  • serialize(attributes,valueSeparator,fieldSeparator,quote)
  • getOrigData(key)
  • setOrigData(key,data)
  • dataHasChangedFor(field)
  • setDataChanges(value)
  • debug(data,objects)
  • offsetSet(offset,value)
  • offsetExists(offset)
  • offsetUnset(offset)
  • offsetGet(offset)
  • isDirty(field)
  • flagDirty(field,flag)

This list was achieved using the php function get_class_methods() and  ReflectionMethod().

For example:

[codesyntax lang=”php” blockstate=”expanded”]

$myCategory = Mage::getModel("catalog/category")->load(11); //id would be some valid category id
$className = get_class($myCategory);  //this will get the actual class name - easier that looking it up yourself :)
echo "<ul>";
foreach(get_class_methods($myCategory ) as $method){
    $r = new ReflectionMethod($className,$method); 
    $params = $r->getParameters();
    echo "<li>";
    echo $method."(";
    $count=0; 
    foreach($params as $param){
        $count++;
        if($count>1){
            echo ",";
        }
        echo $param->getName();
    }
    echo ")</li>";
}
echo "</ul>";

[/codesyntax]

 

You could do the same for the other object types like products, users, etc.

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Apply your human brain cells and complete this highly complicated maths problem *