Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CategoryModel example
/** * @throws ValidationException * @throws Exception * * @return CategoryModel */
public
function
create
(
array
$params
)
{
$this
->
checkPrivilege
(
'create'
)
;
$category
=
new
CategoryModel
(
)
;
$params
=
$this
->
prepareCategoryData
(
$params
)
;
$params
=
$this
->
prepareMediaData
(
$params
,
$category
)
;
$params
=
$this
->
prepareManualSorting
(
$params
,
$category
)
;
$category
->
fromArray
(
$params
)
;
if
(
isset
(
$params
[
'id'
]
)
)
{
$metaData
=
$this
->
getManager
(
)
->
getMetadataFactory
(
)
->
getMetadataFor
(
CategoryModel::
class
)
;
$metaData
->
setIdGeneratorType
(
ClassMetadataInfo::GENERATOR_TYPE_NONE
)
;
$category
->
setPrimaryIdentifier
(
$params
[
'id'
]
)
;
}