magento-2.0.7

Add/remove image programmatically to product Magento2

僤鯓⒐⒋嵵緔 提交于 2019-12-21 02:47:08
问题 I am facing problem to add/remove image to product programmatically. 回答1: Use following code to add/remove image from product in Magento2. // Instance of object manager $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); *Remove Images From Product*/ $productId = ; // Id of product $product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); $productRepository = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface');

Sort by price low to high and high to low in product listing magento2

天涯浪子 提交于 2019-12-06 12:23:18
问题 I am new in magento2. I am using Magento ver. 2.1.1 I want to add custom price low to high and price high to low in Sort By dropdown in product listing page. I didn't get toolbar.phtml page. Also I didn't get any stuff regarding this in google. If anyone have any idea, then please help me. Thanks! 回答1: Step 1: Create plugins in app/code/Vendor/Module/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento

Sort by price low to high and high to low in product listing magento2

女生的网名这么多〃 提交于 2019-12-04 18:23:46
I am new in magento2. I am using Magento ver. 2.1.1 I want to add custom price low to high and price high to low in Sort By dropdown in product listing page. I didn't get toolbar.phtml page. Also I didn't get any stuff regarding this in google. If anyone have any idea, then please help me. Thanks! Step 1: Create plugins in app/code/Vendor/Module/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Block\Product\ProductList\Toolbar"> <plugin

Add/remove image programmatically to product Magento2

£可爱£侵袭症+ 提交于 2019-12-03 08:46:26
I am facing problem to add/remove image to product programmatically. Datta Yadav Use following code to add/remove image from product in Magento2. // Instance of object manager $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); *Remove Images From Product*/ $productId = ; // Id of product $product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); $productRepository = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); $existingMediaGalleryEntries = $product->getMediaGalleryEntries(); foreach ($existingMediaGalleryEntries as