Questions tagged «gallery»


2
Magento 2提供了一种更快的方式以编程方式更改产品媒体库条目
我需要对产品数据进行大量更新,但是产品导入无法实现我需要做的事情。例如,我需要更新给定产品的媒体库和类别,但是我提出的解决方案花费的时间太长。 简要回顾一下:我在Magento 2 CLI中添加了一个命令,给定json配置文件,该命令可以为这样的给定产品删除,添加,更新或排序媒体库条目。在这里粘贴代码摘录: /* $product is of type Magento\Catalog\Model\Product */ //get existing media gallery $existingMediaGallery = $product->getMediaGallery(); /* do stuff with media gallery (alter $existingMediaGallery) (add, remove, sort, ...) */ //set media gallery again $product->setMediaGallery($existingMediaGallery); //process media gallery $mediaGalleryEntries = $product->getMediaGalleryEntries(); $this->getMediaGalleryProcessor()->clearMediaAttribute($product, array_keys($product->getMediaAttributes())); if ($mediaGalleryEntries) { foreach ($mediaGalleryEntries as …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.