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

Public Member Functions

 __construct (FixtureModel $fixtureModel, \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Setup\Fixtures\ImagesGenerator\ImagesGeneratorFactory $imagesGeneratorFactory, \Magento\Framework\Filesystem $filesystem, \Magento\Catalog\Model\Product\Media\Config $mediaConfig, \Magento\Eav\Model\AttributeRepository $attributeRepository, \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $expressionFactory, \Magento\Setup\Model\BatchInsertFactory $batchInsertFactory, \Magento\Framework\EntityManager\MetadataPool $metadataPool)
 
 execute ()
 
 getActionTitle ()
 
 introduceParamLabels ()
 
 printInfo (OutputInterface $output)
 
- Public Member Functions inherited from Fixture
 __construct (FixtureModel $fixtureModel)
 
 execute ()
 
 getActionTitle ()
 
 printInfo (OutputInterface $output)
 
 introduceParamLabels ()
 
 getPriority ()
 

Protected Attributes

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

Detailed Description

Generate images per each product Support next format: <product-images> <images-count>X</images-count> <images-per-product>Y</images-per-product> </product-images>

Where X - number of images to be generated Y - number of images that will be assigned per each product

note, that probably you would need to run command: php bin/magento catalog:images:resize to resize images after generation but be patient with it because it can take pretty much time

See also
setup/performance-toolkit/profiles/ce/small.xml @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 33 of file ImagesFixture.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( FixtureModel  $fixtureModel,
\Magento\Framework\App\ResourceConnection  $resourceConnection,
\Magento\Setup\Fixtures\ImagesGenerator\ImagesGeneratorFactory  $imagesGeneratorFactory,
\Magento\Framework\Filesystem  $filesystem,
\Magento\Catalog\Model\Product\Media\Config  $mediaConfig,
\Magento\Eav\Model\AttributeRepository  $attributeRepository,
\Magento\Framework\DB\Sql\ColumnValueExpressionFactory  $expressionFactory,
\Magento\Setup\Model\BatchInsertFactory  $batchInsertFactory,
\Magento\Framework\EntityManager\MetadataPool  $metadataPool 
)
Parameters
FixtureModel$fixtureModel
\Magento\Framework\App\ResourceConnection$resourceConnection
ImagesGenerator\ImagesGeneratorFactory$imagesGeneratorFactory
\Magento\Framework\Filesystem$filesystem
\Magento\Catalog\Model\Product\Media\Config$mediaConfig
\Magento\Eav\Model\AttributeRepository$attributeRepository
\Magento\Framework\DB\Sql\ColumnValueExpressionFactory$expressionFactory
\Magento\Setup\Model\BatchInsertFactory$batchInsertFactory
\Magento\Framework\EntityManager\MetadataPool$metadataPool

Definition at line 121 of file ImagesFixture.php.

131  {
132  parent::__construct($fixtureModel);
133 
134  $this->imagesGeneratorFactory = $imagesGeneratorFactory;
135  $this->resourceConnection = $resourceConnection;
136  $this->filesystem = $filesystem;
137  $this->mediaConfig = $mediaConfig;
138  $this->attributeRepository = $attributeRepository;
139  $this->expressionFactory = $expressionFactory;
140  $this->batchInsertFactory = $batchInsertFactory;
141  $this->metadataPool = $metadataPool;
142  }
$filesystem
$mediaConfig

Member Function Documentation

◆ execute()

execute ( )

{}

Exceptions

Definition at line 148 of file ImagesFixture.php.

149  {
150  if (!$this->checkIfImagesExists()) {
151  $this->createImageEntities();
152  $this->assignImagesToProducts();
153  }
154  }

◆ getActionTitle()

getActionTitle ( )

{}

Definition at line 159 of file ImagesFixture.php.

160  {
161  return 'Generating images';
162  }

◆ introduceParamLabels()

introduceParamLabels ( )

{}

Definition at line 167 of file ImagesFixture.php.

168  {
169  return [
170  'product-images' => 'Product Images'
171  ];
172  }

◆ printInfo()

printInfo ( OutputInterface  $output)

{}

Exceptions
ValidatorException

Definition at line 178 of file ImagesFixture.php.

179  {
180  $config = $this->fixtureModel->getValue('product-images', []);
181  if (!$config) {
182  return;
183  }
184 
185  if (!isset($config['images-count'])) {
186  throw new ValidatorException(
187  __("The amount of images to generate wasn't specified. Enter the amount and try again.")
188  );
189  }
190 
191  if (!isset($config['images-per-product'])) {
192  throw new ValidatorException(
193  __("The amount of images per product wasn't specified. Enter the amount and try again.")
194  );
195  }
196 
197  $output->writeln(
198  sprintf(
199  '<info> |- Product images: %s, %s per product</info>',
200  $config['images-count'],
201  $config['images-per-product']
202  )
203  );
204  }
$config
Definition: fraud_order.php:17
__()
Definition: __.php:13

Field Documentation

◆ $priority

$priority = 51
protected

Definition at line 38 of file ImagesFixture.php.


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