CategoryRepository
class CategoryRepository extends NestedTreeRepository implements AbstractBlockElementRepositoryInterface
Class CategoryRepository is injected as alligator.category_repository service. CategoryRepository is used for crud operation for managed entity.
Use this class to work with database.
Traits
Constants
| CATEGORY_BLOCKS_RESULT_CACHE |
Category block cache key |
| CATEGORY_TREE_QUERY__RESULT_CACHE |
Category tree query result cache key |
| CATEGORY_TREE_QUERY__RESULT_CACHE_BACKEND_EDIT |
Category tree query backend edit result cache key |
| PRODUCT_ALIAS |
Product alias |
| ALIAS |
Category alias |
| NUMBER_OF_MEGAMENU_ROOT_CATS |
Number of megamenu root categories |
| NUMBER_OF_MEGAMENU_SUB_CATS |
Number of megamenu subcategories |
| PRODUCTS_PER_CATEGORY |
Number of products per category |
Methods
Should contain group by which jqgrid uses.
JQGrid function
JQGrid function
Get Category by name
Get Category by code or null if not found
Get all visible root categories
Get featured categories
Get all categories
Get category ids
Helper function convert to simple array of ids
Get all categories for CSV
Get all categories order by id descending
Get all categories names, ids and slugs
Get all categories names, ids, descriptions and permalink
Get all categories for product add order by id descending
Begin transaction
Flush entity manager
Commit transaction
Save object list from CSV
Get categories from collection
Get root categories
Get root category id and code
Get root category
No description
Get Category tree
Get category tree for backend edit
Save category tree can be used from console command(isCmdAdd should be true than)
Get all categories by ids array for delete
Function that returns ids of all images that categories 'children' contains
Get images id for delete from external links
if you want not to delete subcategories use $this->removeFromTree($cat); method
Get category objects by ids array
Get all categories and brands for category id
Get all category ids
Find all category ids that have children categories
Get all categories id and name
Update number of products in category
Get suggested prices for category filter min and max
Get brands for category id for category filter
Get all category slugs for not deleted categories
Get Category reference
Get Category metadata
Get custom category fields for export
Get parent image path for category with provided id
Get external image by category id
Get external parent image by category id
Get entities from database by ids Tis method is used to for block elements extension Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.self::ALIAS.'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field Also make sure you cache this data -> qb->useQueryCache(true)->useResultCache(true, 3600)
Search categories using Filter, page and offset, if only count is required pass $isCountSearch = true
Get category id and category code
Get all categories id, name and parent id
Save multiple categories accepts flush number as parameter for optimisation purposes
Merge multiple categories from provided array
Get id and name (field must be name so change it in select) of entity Used in event for block element edit Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.self::ALIAS.'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field
Delete all cached results
Param $categories is a string, example "1,2,4,15"
Get left and right data for category
delete all cached results
Get slug of parent category
Update hide from menu property to provided state on categories that match provided slug
Details
in JQGridTrait at line 27
jQGridJoinFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)
All joins used in select.
Override in the repository class if needed. Should do nothing otherwise
in JQGridTrait at line 42
jQGridGroupByFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)
Should contain group by which jqgrid uses.
Override in the repository class if needed. Should do nothing otherwise
in JQGridTrait at line 61
array
findAllForJQGRID(int $page, int $offset, array $sortParams, array $additionalParams, JQGridWrapper $jqGridWrapper)
JQGrid function
in JQGridTrait at line 94
array
searchForJQGRID(array $searchParams, array $sortParams, bool $isCountSearch = false, array $additionalParams = array(), JQGridWrapper $jqGridWrapper = null)
JQGrid function
at line 88
array
getCategoryAndParentDBInstance(Category $category)
Get Category object and its parent object
at line 125
Category
getCategoryByName(String $categoryName)
Get Category by name
at line 149
Category
getDBCategoryByCode(String $categoryCode)
Get Category by code or null if not found
at line 171
Category
getDBCategoryForCategoryPage(Category $category)
Get Category from db for category page
at line 194
array
getAggregatorCategories()
Get all visible root categories
at line 213
array
getFeaturedCats(int $max = 6)
Get featured categories
at line 231
array
getAllCats(null $rootCats = null)
Get all categories
at line 279
array
getCatsIds()
Get category ids
at line 334
array
turnIntoSimpleIdsArray(mixed $arrayOfArrays)
Helper function convert to simple array of ids
at line 348
array
getAllCategoriesForCSV()
Get all categories for CSV
at line 359
array
getAllCategories()
Get all categories order by id descending
at line 372
array
getAllCategoriesIdAndName()
Get all categories names, ids and slugs
at line 386
array
getAllCategoriesIdNameAndDescription()
Get all categories names, ids, descriptions and permalink
at line 398
array
getAllCategoriesForProductAdd()
Get all categories for product add order by id descending
at line 411
beginCustomTransaction()
Begin transaction
at line 419
flush()
Flush entity manager
at line 427
commitCustomTransaction()
Commit transaction
at line 440
mixed
saveCSV(mixed $objectList)
Save object list from CSV
at line 466
ArrayCollection
getCategoriesFromCollection(mixed $array)
Get categories from collection
at line 485
QueryBuilder
getRootCategories(null $limit = null)
Get root categories
at line 503
mixed
getRootFromDb()
Get root category id and code
at line 521
mixed
getRootObjFromDb()
Get root category
at line 541
array|null|string
getCategoryTreePagination(array $options, string|int $id, bool $firstLoad, bool $withRoot, array $additionalCategories)
at line 587
array|string
getCategoryTree(array $options, boolean $displayNonVisible = false)
Get Category tree
at line 667
array|string
getCategoryTreeForEditBackend(array $options, boolean $displayNonVisible = false)
Get category tree for backend edit
at line 715
object
saveTreeCategory(Category $category, boolean $isCmdAdd = false)
Save category tree can be used from console command(isCmdAdd should be true than)
at line 803
mixed
editFields(Category $category)
Edit category fields
at line 847
array
getAllTreeCategoriesForDelete(array $ids)
Get all categories by ids array for delete
at line 867
array
getImagesIdsForDelete(int $categoryId)
Function that returns ids of all images that categories 'children' contains
at line 886
array
getImagesIdsForDeleteFromExternalLinks(int $categoryId)
Get images id for delete from external links
at line 907
int
deleteTreeCategories(array $objects)
if you want not to delete subcategories use $this->removeFromTree($cat); method
at line 930
ArrayCollection
getCategoryObjectsById(array $array)
Get category objects by ids array
at line 950
array
getDBCategoryIDBySlug(Category $category)
Get category id by slug
at line 969
array
getDBCategoryFilterDataBySlug(Category $category)
Get category left, right and id from db by slug
at line 988
mixed
findAllCategoriesWithContainingBrands(int $categoryId)
Get all categories and brands for category id
at line 1031
array
findAllCategoriesIds()
Get all category ids
at line 1047
mixed
findAllParentCategories(int $id, int $lft, int $rgt)
Find all category ids that have children categories
at line 1064
array
findCategoriesForCatAdd()
Get all categories id and name
at line 1075
updateFromCMD()
Update number of products in category
at line 1120
array
getSuggestedPrices(int $categoryId, int|null $lft = null, int|null $rgt = null)
Get suggested prices for category filter min and max
at line 1149
array
getSuggestedBrandsIds(int $categoryId)
Get brands for category id for category filter
at line 1170
boolean
updateDisplayForSubCats(Category $rootCategory)
Update visibility for categories
at line 1195
array
getCategoriesSlugs()
Get all category slugs for not deleted categories
at line 1212
mixed
getCategoryReference(int $id)
Get Category reference
at line 1221
mixed
getCategoryMetadata()
Get Category metadata
at line 1232
mixed
getCustomCategoryFieldsForExport(array $fields)
Get custom category fields for export
at line 1273
array
getParentImageWebPathForCategory(int $id)
Get parent image path for category with provided id
at line 1292
array
getExternalImageByCatId(int $id)
Get external image by category id
at line 1311
array
getExternalParentImageByCatId(int $id)
Get external parent image by category id
at line 1334
array
getEntitiesForBlockElementsExtension(array $ids)
Get entities from database by ids Tis method is used to for block elements extension Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.self::ALIAS.'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field Also make sure you cache this data -> qb->useQueryCache(true)->useResultCache(true, 3600)
at line 1376
array
searchCategories(Filter $filter, int $page, int $offset, bool $isCountSearch = false)
Search categories using Filter, page and offset, if only count is required pass $isCountSearch = true
at line 1414
array
getAllCategoriesIdAndCode()
Get category id and category code
at line 1427
mixed
getAllCategoriesIdNameAndParentId()
Get all categories id, name and parent id
at line 1446
bool|string
saveMultiple(array $categories, int $flushNumber = 30, bool $hasNewCategory = false)
Save multiple categories accepts flush number as parameter for optimisation purposes
at line 1487
bool
mergeMultiple(array $array = array())
Merge multiple categories from provided array
at line 1512
array
getEntityNamesForIds(array $ids)
Get id and name (field must be name so change it in select) of entity Used in event for block element edit Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.self::ALIAS.'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field
at line 1529
deleteResultCaches()
Delete all cached results
at line 1544
bool
updateProductPermissionsForCategories(string $categories)
Param $categories is a string, example "1,2,4,15"
at line 1566
array
getLftRgtData(mixed $category)
Get left and right data for category
at line 1582
deleteTreeQueryResultResultCaches()
delete all cached results
at line 1597
mixed
getParentCategorySlug(string $slug = '')
Get slug of parent category
at line 1624
mixed
getHighestLevelParent(Category $category)
Get highest level parent category for provided category
at line 1642
hideCategoriesForSlug(string $slug, bool $hide)
Update hide from menu property to provided state on categories that match provided slug