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
Catalog
_files
product_image.php
Go to the documentation of this file.
1
<?php
7
use
Magento\Framework\App\Filesystem\DirectoryList
;
8
9
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
11
$mediaConfig
=
$objectManager
->get(\
Magento
\Catalog\Model\Product\Media\Config::class);
12
14
$mediaDirectory
=
$objectManager
->get(\
Magento
\Framework\Filesystem::class)
15
->getDirectoryWrite(DirectoryList::MEDIA);
16
$targetDirPath
=
$mediaConfig
->getBaseMediaPath() . str_replace(
'/'
, DIRECTORY_SEPARATOR,
'/m/a/'
);
17
$targetTmpDirPath
=
$mediaConfig
->getBaseTmpMediaPath() . str_replace(
'/'
, DIRECTORY_SEPARATOR,
'/m/a/'
);
18
$mediaDirectory
->create(
$targetDirPath
);
19
$mediaDirectory
->create(
$targetTmpDirPath
);
20
21
$targetTmpFilePath
=
$mediaDirectory
->getAbsolutePath() . DIRECTORY_SEPARATOR .
$targetTmpDirPath
22
. DIRECTORY_SEPARATOR .
'magento_image.jpg'
;
23
copy(
__DIR__
.
'/magento_image.jpg'
,
$targetTmpFilePath
);
24
// Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir
$targetTmpFilePath
$targetTmpFilePath
Definition:
product_image.php:21
__DIR__
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition:
_bootstrap.php:60
$objectManager
$objectManager
Definition:
product_image.php:9
$targetTmpDirPath
$targetTmpDirPath
Definition:
product_image.php:17
$targetDirPath
$targetDirPath
Definition:
product_image.php:16
Magento
Magento\Framework\App\Filesystem\DirectoryList
Definition:
DirectoryList.php:13
$mediaDirectory
$mediaDirectory
Definition:
product_image.php:14
$mediaConfig
$mediaConfig
Definition:
product_image.php:11
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125