Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
CatalogImportExport
_files
product_export_with_images.php
Go to the documentation of this file.
1
<?php
7
require dirname(
__DIR__
, 2) .
'/Catalog/_files/product_image.php'
;
8
require dirname(
__DIR__
, 2) .
'/Catalog/_files/product_simple.php'
;
9
10
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
12
$productRepository
=
$objectManager
->create(\
Magento
\Catalog\Api\ProductRepositoryInterface::class);
13
$product
=
$productRepository
->get(
'simple'
);
14
$product
->setStoreId(0)
15
->setImage(
'/m/a/magento_image.jpg'
)
16
->setSmallImage(
'/m/a/magento_image.jpg'
)
17
->setThumbnail(
'/m/a/magento_image.jpg'
)
18
->setData(
19
'media_gallery'
,
20
[
21
'images'
=> [
22
[
23
'file'
=>
'/m/a/magento_image.jpg'
,
24
'position'
=> 1,
25
'label'
=>
'Image Alt Text'
,
26
'disabled'
=> 0,
27
'media_type'
=>
'image'
,
28
],
29
],
30
]
31
)->save();
32
$image
= array_shift(
$product
->getData(
'media_gallery'
)[
'images'
]);
33
$product
=
$productRepository
->get(
'simple'
,
false
, 1,
true
);
34
$product
->setData(
35
'media_gallery'
,
36
[
37
'images'
=> [
38
[
39
'value_id'
=>
$image
[
'value_id'
],
40
'file'
=>
$image
[
'file'
],
41
'disabled'
=> 1,
42
'media_type'
=>
'image'
,
43
],
44
],
45
]
46
);
47
$productRepository
->save(
$product
);
__DIR__
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition:
_bootstrap.php:60
$image
$image
Definition:
product_export_with_images.php:32
$product
$product
Definition:
product_export_with_images.php:13
$objectManager
$objectManager
Definition:
product_export_with_images.php:10
Magento
$productRepository
$productRepository
Definition:
product_export_with_images.php:12
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125