@@ -192,14 +192,21 @@ public function addEntityType($code, array $params)
192192 'additional_attribute_table ' => $ this ->_getValue ($ params , 'additional_attribute_table ' ),
193193 'entity_attribute_collection ' => $ this ->_getValue ($ params , 'entity_attribute_collection ' ),
194194 ];
195+ if (isset ($ params ['entity_type_id ' ])) {
196+ $ data ['entity_type_id ' ] = $ params ['entity_type_id ' ];
197+ }
195198
196199 if ($ this ->getEntityType ($ code , 'entity_type_id ' )) {
197200 $ this ->updateEntityType ($ code , $ data );
198201 } else {
199202 $ this ->setup ->getConnection ()->insert ($ this ->setup ->getTable ('eav_entity_type ' ), $ data );
200203 }
201204
202- $ this ->addAttributeSet ($ code , $ this ->_defaultAttributeSetName );
205+ if (isset ($ params ['entity_type_id ' ])) {
206+ $ this ->addAttributeSet ($ code , $ this ->_defaultAttributeSetName , null , $ params ['entity_type_id ' ]);
207+ } else {
208+ $ this ->addAttributeSet ($ code , $ this ->_defaultAttributeSetName );
209+ }
203210 $ this ->addAttributeGroup ($ code , $ this ->_defaultGroupName , $ this ->_generalGroupName );
204211
205212 return $ this ;
@@ -310,16 +317,21 @@ public function getAttributeSetSortOrder($entityTypeId, $sortOrder = null)
310317 * @param int|string $entityTypeId
311318 * @param string $name
312319 * @param int $sortOrder
320+ * @param int $setId
313321 * @return $this
314322 */
315- public function addAttributeSet ($ entityTypeId , $ name , $ sortOrder = null )
323+ public function addAttributeSet ($ entityTypeId , $ name , $ sortOrder = null , $ setId = null )
316324 {
317325 $ data = [
318326 'entity_type_id ' => $ this ->getEntityTypeId ($ entityTypeId ),
319327 'attribute_set_name ' => $ name ,
320328 'sort_order ' => $ this ->getAttributeSetSortOrder ($ entityTypeId , $ sortOrder ),
321329 ];
322330
331+ if ($ setId !== null ) {
332+ $ data ['attribute_set_id ' ] = $ setId ;
333+ }
334+
323335 $ setId = $ this ->getAttributeSet ($ entityTypeId , $ name , 'attribute_set_id ' );
324336 if ($ setId ) {
325337 $ this ->updateAttributeSet ($ entityTypeId , $ setId , $ data );
0 commit comments