Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
CustomerGroupsFixture Class Reference
Inheritance diagram for CustomerGroupsFixture:
Fixture

Public Member Functions

 __construct (FixtureModel $fixtureModel, CollectionFactory $groupCollectionFactory, GroupRepositoryInterface $groupRepository, GroupInterfaceFactory $groupFactory)
 
 execute ()
 
 getActionTitle ()
 
 introduceParamLabels ()
 
- Public Member Functions inherited from Fixture
 __construct (FixtureModel $fixtureModel)
 
 execute ()
 
 getActionTitle ()
 
 printInfo (OutputInterface $output)
 
 introduceParamLabels ()
 
 getPriority ()
 

Data Fields

const DEFAULT_TAX_CLASS_ID = 3
 

Protected Attributes

 $priority = 60
 
- Protected Attributes inherited from Fixture
 $priority
 
 $fixtureModel
 

Detailed Description

Fixture for creating a Customer Groups

Definition at line 16 of file CustomerGroupsFixture.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( FixtureModel  $fixtureModel,
CollectionFactory  $groupCollectionFactory,
GroupRepositoryInterface  $groupRepository,
GroupInterfaceFactory  $groupFactory 
)

@inheritDoc

Definition at line 43 of file CustomerGroupsFixture.php.

48  {
49  parent::__construct($fixtureModel);
50  $this->groupCollectionFactory = $groupCollectionFactory;
51  $this->groupRepository = $groupRepository;
52  $this->groupFactory = $groupFactory;
53  }
$groupRepository
$groupFactory

Member Function Documentation

◆ execute()

execute ( )

Definition at line 58 of file CustomerGroupsFixture.php.

59  {
60  $existingCustomerGroupsCount = $this->groupCollectionFactory->create()->getSize();
61  $customerGroupsCount = $this->fixtureModel->getValue('customer_groups', 0);
62  if ($customerGroupsCount < 1) {
63  return;
64  }
65 
66  for ($i = $existingCustomerGroupsCount; $i < $customerGroupsCount; ++$i) {
67  $groupDataObject = $this->groupFactory->create();
69  ->setCode('customer_group_' . $i)
70  ->setTaxClassId(self::DEFAULT_TAX_CLASS_ID);
71  $this->groupRepository->save($groupDataObject);
72  }
73  }
$groupDataObject
$i
Definition: gallery.phtml:31

◆ getActionTitle()

getActionTitle ( )

Definition at line 78 of file CustomerGroupsFixture.php.

79  {
80  return 'Generating customer groups';
81  }

◆ introduceParamLabels()

introduceParamLabels ( )

Definition at line 86 of file CustomerGroupsFixture.php.

87  {
88  return [
89  'customer_groups' => 'Customer groups'
90  ];
91  }

Field Documentation

◆ $priority

$priority = 60
protected

Definition at line 23 of file CustomerGroupsFixture.php.

◆ DEFAULT_TAX_CLASS_ID

const DEFAULT_TAX_CLASS_ID = 3

Definition at line 18 of file CustomerGroupsFixture.php.


The documentation for this class was generated from the following file: