Skip to content

magento man

Magento 2 set product image role programmatically

Hello and this is my code: $imgURL = ‘path/to/my/image.png’; $fileSystem = $objectManager->create(‘MagentoFrameworkFilesystem’); $mediaPath = $fileSystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath(); $product->addImageToMediaGallery($mediaPath.’catalog/product’.$data[‘thumbnail_image’],[‘thumbnail’, ‘swatch’], false, false); $product->setThumbnail($mediaPath.’catalog/product’.$imgURL); $product->save(); What I want to achive, is to assign programmatically an image and set it as a thumbnail. The above… Read More »Magento 2 set product image role programmatically

Facing this issue, It contains 1 abstract method and must therefore be declared abstract or implement the remaining method

Facing fatal error given as below. Fatal error: Class SugarcodeTestModelTotalFee contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MagentoFrameworkDataObjectIdentityInterface::getIdentities) in /home/dukaania/public_html/testing2/app/code/Sugarcode/Test/Model/Total/Fee.php on line 7 Here is my code <?php /** * Copyright ©… Read More »Facing this issue, It contains 1 abstract method and must therefore be declared abstract or implement the remaining method

Rewrite rule for media images

we need to set rewrite rule for some images in Magento 2.2.5 using .htaccess rules or nginx conf Example 1 Request Path: https://www.example.com//media/catalog/product/cache/1/thumbnail/543×403/db978388cfd007780066eaab38556cef/n/u/number1.png Response Path: https://www.example.com/pub/media/catalog/product/cache/543×403/n/u/number1.png Example 2 Request Path : https://www.example.com/media/catalog/product/cache/1/thumbnail/543×403/db978388cfd007780066eaab38556cef/l/e/legal_slide01.jpg Response Path : https://www.example.com/pub/media/catalog/product/cache/543×403/l/e/legal_slide01.jpg Here the l/e/ directories… Read More »Rewrite rule for media images