Insert product images on multiple websites problem #14413
Labels
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Priority: P3
May be fixed according to the position in the backlog.
Progress: done
Reproduced on 2.1.x
The issue has been reproduced on latest 2.1 release
Reproduced on 2.2.x
The issue has been reproduced on latest 2.2 release
Reproduced on 2.3.x
The issue has been reproduced on latest 2.3 release
Severity: S3
Affects non-critical data or functionality and does not force users to employ a workaround.
stale issue
I have created a script to insert images into products, the images are inserted correctly but the labels and roles do not do it for all websites, only for the default website
Preconditions
Magento 2.2.3
Php 7.1
Centos 7 with CPANEL
I configure 3 Websites and theirs views
Steps to reproduce
`
use Magento\Framework\App\Bootstrap;
include('../app/bootstrap.php');
// Get all premium products
$pps = $db->query_array("SELECT id_producto, sku FROM productos_has_tienda");
// Magento bootstrap
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
// Product repository object
$productRepository = $objectManager->get('\Magento\Catalog\Model\ProductRepository');
// mediaGalleryProcessor
$mediaGalleryProcessor = $objectManager->get('Magento\Catalog\Model\Product\Gallery\Processor');
// Image content object
$imageContent = $objectManager->get('\Magento\Framework\Api\Data\ImageContentInterfaceFactory');
// Image processor
$imageProcessor = $objectManager->get('Magento\Framework\Api\ImageProcessorInterface');
// Get all products to import
$pps = $db->query_array("SELECT id_producto, sku FROM productos_has_tienda");
// for each product to import
foreach ($pps as $p){
$product = $productRepository->get($p['sku']);
echo $product->getName()."\n";
echo "Insert images...\n";
$images = $db->query_array("
SELECT s3_name
FROM productos_imagen
WHERE id_producto = ".$p['id_producto']."
ORDER BY id_imagen ASC
");
$ci = 0;
foreach ($images as $i){
$newEntry = array();
$newEntry['disabled'] = false;
$newEntry['label'] = $product->getName();
$newEntry['position'] = $ci;
$newEntry['media_type'] = "image";
($ci == 0) ? $newEntry['types'] = ['image', 'small_image', 'thumbnail'] : $newEntry['types'] = [];
}
$product->save();
}
`
Expected result
Insert images with labels and roles in all websites
Actual result
Only in the default website the images have label and roles
The text was updated successfully, but these errors were encountered: