Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Data Fields | |
const | ENTITY = 'catalog_category' |
const | DM_PRODUCT = 'PRODUCTS' |
const | DM_PAGE = 'PAGE' |
const | DM_MIXED = 'PRODUCTS_AND_PAGE' |
const | ROOT_CATEGORY_ID = 0 |
const | TREE_ROOT_ID = 1 |
const | CACHE_TAG = 'cat_c' |
![]() | |
const | CUSTOM_ATTRIBUTES = 'custom_attributes' |
![]() | |
const | EXTENSION_ATTRIBUTES_KEY = 'extension_attributes' |
![]() | |
const | KEY_PARENT_ID = 'parent_id' |
const | KEY_NAME = 'name' |
const | KEY_IS_ACTIVE = 'is_active' |
const | KEY_POSITION = 'position' |
const | KEY_LEVEL = 'level' |
const | KEY_UPDATED_AT = 'updated_at' |
const | KEY_CREATED_AT = 'created_at' |
const | KEY_PATH = 'path' |
const | KEY_AVAILABLE_SORT_BY = 'available_sort_by' |
const | KEY_INCLUDE_IN_MENU = 'include_in_menu' |
const | KEY_PRODUCT_COUNT = 'product_count' |
const | KEY_CHILDREN_DATA = 'children_data' |
const | ATTRIBUTES |
Protected Member Functions | |
_construct () | |
getCustomAttributesCodes () | |
_getResource () | |
![]() | |
filterCustomAttributes ($data) | |
initializeCustomAttributes () | |
convertCustomAttributeValues (array &$customAttributes) | |
getCustomAttributesCodes () | |
_setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes) | |
_getExtensionAttributes () | |
![]() | |
_construct () | |
_init ($resourceModel) | |
_setResourceModel ($resourceName, $collectionName=null) | |
_getResource () | |
_getEventData () | |
_beforeLoad ($modelId, $field=null) | |
_afterLoad () | |
_hasModelChanged () | |
_getValidatorBeforeSave () | |
_createValidatorBeforeSave () | |
_getValidationRulesBeforeSave () | |
_clearReferences () | |
_clearData () | |
![]() | |
_getData ($key) | |
_underscore ($name) | |
Additional Inherited Members | |
![]() | |
static | $_underscoreCache = [] |
Catalog category
@api @method Category setAffectedProductIds(array $productIds) @method array getAffectedProductIds() @method Category setMovedCategoryId(array $productIds) @method int getMovedCategoryId() @method Category setAffectedCategoryIds(array $categoryIds) @method array getAffectedCategoryIds() @method Category setUrlKey(string $urlKey) @method Category setUrlPath(string $urlPath) @method Category getSkipDeleteChildren() @method Category setSkipDeleteChildren(boolean $value) @method Category setChangedProductIds(array $categoryIds) Set products ids that inserted or deleted for category @method array getChangedProductIds() Get products ids that inserted or deleted for category
@SuppressWarnings(PHPMD.LongVariable) @SuppressWarnings(PHPMD.ExcessivePublicCount) @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Definition at line 42 of file Category.php.
__construct | ( | \Magento\Framework\Model\Context | $context, |
\Magento\Framework\Registry | $registry, | ||
\Magento\Framework\Api\ExtensionAttributesFactory | $extensionFactory, | ||
AttributeValueFactory | $customAttributeFactory, | ||
\Magento\Store\Model\StoreManagerInterface | $storeManager, | ||
\Magento\Catalog\Api\CategoryAttributeRepositoryInterface | $metadataService, | ||
\Magento\Catalog\Model\ResourceModel\Category\Tree | $categoryTreeResource, | ||
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory | $categoryTreeFactory, | ||
\Magento\Store\Model\ResourceModel\Store\CollectionFactory | $storeCollectionFactory, | ||
\Magento\Framework\UrlInterface | $url, | ||
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory | $productCollectionFactory, | ||
\Magento\Catalog\Model\Config | $catalogConfig, | ||
\Magento\Framework\Filter\FilterManager | $filter, | ||
Indexer\Category\Flat\State | $flatState, | ||
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator | $categoryUrlPathGenerator, | ||
UrlFinderInterface | $urlFinder, | ||
\Magento\Framework\Indexer\IndexerRegistry | $indexerRegistry, | ||
CategoryRepositoryInterface | $categoryRepository, | ||
\Magento\Framework\Model\ResourceModel\AbstractResource | $resource = null , |
||
\Magento\Framework\Data\Collection\AbstractDb | $resourceCollection = null , |
||
array | $data = [] |
||
) |
\Magento\Framework\Model\Context | $context | |
\Magento\Framework\Registry | $registry | |
\Magento\Framework\Api\ExtensionAttributesFactory | $extensionFactory | |
AttributeValueFactory | $customAttributeFactory | |
\Magento\Store\Model\StoreManagerInterface | $storeManager | |
\Magento\Catalog\Api\CategoryAttributeRepositoryInterface | $metadataService | |
\Magento\Catalog\Model\ResourceModel\Category\Tree | $categoryTreeResource | |
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory | $categoryTreeFactory | |
\Magento\Store\Model\ResourceModel\Store\CollectionFactory | $storeCollectionFactory | |
\Magento\Framework\UrlInterface | $url | |
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory | $productCollectionFactory | |
Config | $catalogConfig | |
\Magento\Framework\Filter\FilterManager | $filter | |
Indexer\Category\Flat\State | $flatState | |
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator | $categoryUrlPathGenerator | |
UrlFinderInterface | $urlFinder | |
\Magento\Framework\Indexer\IndexerRegistry | $indexerRegistry | |
CategoryRepositoryInterface | $categoryRepository | |
\Magento\Framework\Model\ResourceModel\AbstractResource | $resource | |
\Magento\Framework\Data\Collection\AbstractDb | $resourceCollection | |
array | $data | @SuppressWarnings(PHPMD.ExcessiveParameterList) |
Definition at line 239 of file Category.php.
__toArray | ( | ) |
|
protected |
|
protected |
Definition at line 321 of file Category.php.
afterDeleteCommit | ( | ) |
Init indexing process after category delete
Definition at line 1129 of file Category.php.
afterSave | ( | ) |
Add reindexCallback
Definition at line 1092 of file Category.php.
beforeDelete | ( | ) |
checkId | ( | $id | ) |
Check category id existing
int | $id |
Definition at line 824 of file Category.php.
formatUrlKey | ( | $str | ) |
Format URL key from name or defined key
string | $str |
Definition at line 647 of file Category.php.
getAllChildren | ( | $asArray = false | ) |
Get all children categories IDs
boolean | $asArray | return result as array instead of comma-separated list of IDs |
Definition at line 776 of file Category.php.
getAnchorsAbove | ( | ) |
getAttributes | ( | $noDesignAttributes = false | ) |
Retrieve all customer attributes
bool | $noDesignAttributes |
Definition at line 482 of file Category.php.
getAvailableSortBy | ( | ) |
Retrieve Available int Product Listing sort by
Implements CategoryInterface.
Definition at line 1020 of file Category.php.
getAvailableSortByOptions | ( | ) |
Retrieve Available Product Listing Sort By code as key, value - name
Definition at line 1038 of file Category.php.
getCategories | ( | $parent, | |
$recursionLevel = 0 , |
|||
$sorted = false , |
|||
$asCollection = false , |
|||
$toLoad = true |
|||
) |
Retrieve categories by parent
int | $parent | |
int | $recursionLevel | |
bool | $sorted | |
bool | $asCollection | |
bool | $toLoad |
Definition at line 968 of file Category.php.
getCategoryId | ( | ) |
Definition at line 1207 of file Category.php.
getCategoryIdUrl | ( | ) |
Retrieve category id URL
Definition at line 632 of file Category.php.
Retrieve children ids comma separated
boolean | $recursive | |
boolean | $isActive | |
boolean | $sortByPosition |
Definition at line 794 of file Category.php.
getChildrenCategories | ( | ) |
Return children categories of current category
Definition at line 989 of file Category.php.
getChildrenCount | ( | ) |
Definition at line 1174 of file Category.php.
getChildrenData | ( | ) |
Implements CategoryTreeInterface.
Definition at line 1239 of file Category.php.
getCreatedAt | ( | ) |
Implements CategoryInterface.
Definition at line 1182 of file Category.php.
|
protected |
{}
Definition at line 306 of file Category.php.
getCustomDesignDate | ( | ) |
Retrieve dates for custom design (from & to)
Definition at line 731 of file Category.php.
getDefaultAttributeSetId | ( | ) |
getDefaultSortBy | ( | ) |
Retrieve Product Listing Default Sort By
Definition at line 1062 of file Category.php.
getDesignAttributes | ( | ) |
getDisplayMode | ( | ) |
Definition at line 1215 of file Category.php.
getExtensionAttributes | ( | ) |
{Retrieve existing extension attributes object or create a new one.
Implements CategoryInterface.
Definition at line 1421 of file Category.php.
getIdentities | ( | ) |
Get identities
Implements IdentityInterface.
Definition at line 1140 of file Category.php.
getImageUrl | ( | $attributeCode = 'image' | ) |
string | $attributeCode |
Definition at line 657 of file Category.php.
getIncludeInMenu | ( | ) |
Implements CategoryInterface.
Definition at line 1223 of file Category.php.
getIsActive | ( | ) |
Implements CategoryInterface.
Definition at line 1199 of file Category.php.
getLevel | ( | ) |
Retrieve level
Implements CategoryInterface.
Definition at line 850 of file Category.php.
getName | ( | ) |
Retrieve Name data wrapper
Implements CategoryInterface.
Definition at line 894 of file Category.php.
getParentCategories | ( | ) |
Return parent categories of current category
Return parent categories of category
\Magento\Catalog\Model\Category | $category |
Definition at line 979 of file Category.php.
getParentCategory | ( | ) |
Get parent category object
Definition at line 693 of file Category.php.
getParentDesignCategory | ( | ) |
Return parent category of current category with own custom design settings
Definition at line 999 of file Category.php.
getParentId | ( | ) |
Get parent category identifier
Implements CategoryInterface.
Definition at line 706 of file Category.php.
getParentIds | ( | ) |
getPath | ( | ) |
@codeCoverageIgnoreStart
Implements CategoryInterface.
Definition at line 1158 of file Category.php.
getPathIds | ( | ) |
Get array categories ids which are part of category path Result array contain id of current category because it is part of the path
Definition at line 835 of file Category.php.
getPathInStore | ( | ) |
Retrieve Stores where isset category Path Return comma separated string
Definition at line 805 of file Category.php.
getPosition | ( | ) |
Implements CategoryInterface.
Definition at line 1166 of file Category.php.
getProductCollection | ( | ) |
Get category products collection
\Magento\Catalog\Model\Category | $category | |
int | $storeId |
Definition at line 464 of file Category.php.
getProductCount | ( | ) |
Retrieve count products of category
Implements CategoryTreeInterface.
Definition at line 948 of file Category.php.
getProductsPosition | ( | ) |
Retrieve array of product id's for category
The array returned has the following format: array($productId => $position)
Definition at line 505 of file Category.php.
getRequestPath | ( | ) |
getStoreId | ( | ) |
Return store id.
If store id is underfined for category return current active store id
Definition at line 569 of file Category.php.
getStoreIds | ( | ) |
Retrieve array of store ids for category
Definition at line 524 of file Category.php.
getTreeModel | ( | ) |
Retrieve category tree model
Definition at line 352 of file Category.php.
getTreeModelInstance | ( | ) |
Enter description here...
Definition at line 362 of file Category.php.
getUpdatedAt | ( | ) |
Implements CategoryInterface.
Definition at line 1190 of file Category.php.
getUrl | ( | ) |
Get category url
Definition at line 598 of file Category.php.
getUrlInstance | ( | ) |
Retrieve URL instance
Definition at line 342 of file Category.php.
getUrlKey | ( | ) |
Definition at line 1231 of file Category.php.
getUseFlatResource | ( | ) |
Get flat resource model flag
Definition at line 332 of file Category.php.
hasChildren | ( | ) |
isInRootCategoryList | ( | ) |
Check category is in Root Category list
Definition at line 1009 of file Category.php.
move | ( | $parentId, | |
$afterCategoryId | |||
) |
Move category
int | $parentId | new parent category id |
null | int | $afterCategoryId | category id after which we have put current category |
Validate new parent category id. (category model is used for backward compatibility in event params)
Setting affected category ids for third party engine index refresh
Definition at line 375 of file Category.php.
reindex | ( | ) |
Init indexing process after category save
Definition at line 1104 of file Category.php.
setAvailableSortBy | ( | $availableSortBy | ) |
string[]|string | $availableSortBy |
Implements CategoryInterface.
Definition at line 1382 of file Category.php.
setChildrenData | ( | array | $childrenData = null | ) |
Implements CategoryTreeInterface.
Definition at line 1411 of file Category.php.
setCreatedAt | ( | $createdAt | ) |
string | $createdAt |
Implements CategoryInterface.
Definition at line 1364 of file Category.php.
setExtensionAttributes | ( | \Magento\Catalog\Api\Data\CategoryExtensionInterface | $extensionAttributes | ) |
{Set an extension attributes object.
\Magento\Catalog\Api\Data\CategoryExtensionInterface | $extensionAttributes |
\Magento\Catalog\Api\Data\CategoryExtensionInterface | $extensionAttributes |
Implements CategoryInterface.
Definition at line 1432 of file Category.php.
setIncludeInMenu | ( | $includeInMenu | ) |
bool | $includeInMenu |
Implements CategoryInterface.
Definition at line 1391 of file Category.php.
setIsActive | ( | $isActive | ) |
Set whether category is active
bool | $isActive |
Implements CategoryInterface.
Definition at line 1324 of file Category.php.
setLevel | ( | $level | ) |
Set category level
int | $level |
Implements CategoryInterface.
Definition at line 1346 of file Category.php.
setName | ( | $name | ) |
Set category name
string | $name |
Implements CategoryInterface.
Definition at line 1313 of file Category.php.
setParentId | ( | $parentId | ) |
Set parent category ID
int | $parentId |
Implements CategoryInterface.
Definition at line 1302 of file Category.php.
setPath | ( | $path | ) |
string | $path |
Implements CategoryInterface.
Definition at line 1373 of file Category.php.
setPosition | ( | $position | ) |
Set category position
int | $position |
Implements CategoryInterface.
Definition at line 1335 of file Category.php.
setProductCount | ( | $productCount | ) |
Set product count
int | $productCount |
Implements CategoryTreeInterface.
Definition at line 1402 of file Category.php.
setStoreId | ( | $storeId | ) |
Set store id
int | string | $storeId |
Definition at line 583 of file Category.php.
setUpdatedAt | ( | $updatedAt | ) |
string | $updatedAt |
Implements CategoryInterface.
Definition at line 1355 of file Category.php.
validate | ( | ) |
verifyIds | ( | array | $ids | ) |
|
protected |
Definition at line 90 of file Category.php.
|
protected |
Definition at line 162 of file Category.php.
|
protected |
Definition at line 183 of file Category.php.
|
protected |
Definition at line 125 of file Category.php.
|
protected |
Definition at line 83 of file Category.php.
|
protected |
#-
Definition at line 76 of file Category.php.
|
protected |
Definition at line 169 of file Category.php.
|
protected |
Definition at line 103 of file Category.php.
|
protected |
Definition at line 176 of file Category.php.
|
protected |
Definition at line 148 of file Category.php.
|
protected |
Definition at line 97 of file Category.php.
|
protected |
Definition at line 111 of file Category.php.
|
protected |
Definition at line 118 of file Category.php.
|
protected |
Definition at line 208 of file Category.php.
|
protected |
Definition at line 193 of file Category.php.
|
protected |
Definition at line 155 of file Category.php.
|
protected |
Definition at line 188 of file Category.php.
|
protected |
Definition at line 203 of file Category.php.
|
protected |
Definition at line 141 of file Category.php.
|
protected |
Definition at line 213 of file Category.php.
|
protected |
Definition at line 198 of file Category.php.
const CACHE_TAG = 'cat_c' |
Definition at line 73 of file Category.php.
const DM_MIXED = 'PRODUCTS_AND_PAGE' |
Definition at line 60 of file Category.php.
const DM_PAGE = 'PAGE' |
Definition at line 58 of file Category.php.
const DM_PRODUCT = 'PRODUCTS' |
#+ Category display modes
Definition at line 56 of file Category.php.
const ENTITY = 'catalog_category' |
Entity code. Can be used as part of method name for entity processing
Definition at line 51 of file Category.php.
const ROOT_CATEGORY_ID = 0 |
#- Id of root category
Definition at line 66 of file Category.php.
const TREE_ROOT_ID = 1 |
Id of category tree root
Definition at line 71 of file Category.php.