Hot answers tagged

2 votes

How i get product id in aroundExcute function?

From what I understand you are building a plugin for this method Magento\CatalogStaging\Model\ProductApplier::execute. If this is true, then your plugin aroundExecute method should looke like this ...
Marius's user avatar
  • 198k
2 votes

How to add custom sort like Most View and Best Selling products in API of Product List in Magento 2?

For custom sort filter through api, you need to create custom module, Create app/code/Custom/Sort/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
Mitul Vadalia's user avatar
2 votes
Accepted

Magento2 catalog product edit related

Your modifier does not remove the Related config from the $meta because its sort order is smaller than the sort order of the Related modifier (sortOrder 110). As a result, your modifier (sortOrder 10) ...
Tu Van's user avatar
  • 6,763
2 votes
Accepted

Preference Module - When to Pass in Parent Dependencies

dependencies and constructors are conditional if you're referring to preference/overriding class. if you're using another dependencies which are not in parent class, you need to declare __construct ...
Fiko's user avatar
  • 106
2 votes
Accepted

Add a link to the SKU of the product in the order details in the backend

Create file app/code/Tarun/StackOverflow/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=&...
Tarun Bhalodia's user avatar
1 vote
Accepted

updating product description via coding correctly shows text on product page but admin side's edit description with pagebuilder shows old values?

We faced the same issue while saving products using REST API. The issue is already raised in Github. https://github.com/magento/magento2/issues/8897 The issue: While saving the product with ...
Lokesh Naik's user avatar
1 vote
Accepted

Get product categories not using ObjectManager

There are multiple ways to create the class but it also depends where you will use it. like Case1: If you want to the use the class in phtml file then you can create the Block or viewModels class. ...
Deepak MageDivine's user avatar
1 vote

Special Price Updating unknowingly - Magento 2

If you are suspect it is API request cause this issue. You can check the API define and codes logic to chech whether it is updating special_price of product. If you are not sure where cause this issue ...
Zoe's user avatar
  • 51
1 vote

Condition for moving elements

For configurable products you can use separate layout file i.e catalog_product_view_type_configurable.xml You can check default file at: vendor/magento/module-configurable-product/view/frontend/...
Pawan's user avatar
  • 5,846
1 vote
Accepted

Add price with carton and price without carton

You can use the "Customizable options" in order to allow the customer to choose if they want to add this option or not. Here is an example of a configuration you might need : For other ...
Cladiuss's user avatar
  • 1,261
1 vote
Accepted

Porto theme - Magento2 - Product page - Image position

You can use the Sticky widget from Magento. Here is a link to the official documentation : https://developer.adobe.com/commerce/frontend-core/javascript/jquery-widgets/sticky/ Here is an example of an ...
Cladiuss's user avatar
  • 1,261
1 vote

Status and visibility can not be set after copying a product programmatically?

To properly set the visibility and status of a copied product in Magento without setting their scope to global, you can follow these steps: 1)Inject the \Magento\Catalog\Api\Data\...
Hikmadh Commerce's user avatar
1 vote

Preference Module - When to Pass in Parent Dependencies

When you are extending from your parent class, it get the all things. If you want to use new classes then you can inject them in your child class. For more details you can get best info from there : ...
Rana Zain's user avatar
  • 642
1 vote

Preference Module - When to Pass in Parent Dependencies

You can use plugin <?php namespace Test\Catalog\Plugin; class Product { public function afterGetName(\Magento\Catalog\Model\Product $subject, $result) { return 'Test ' . $result; ...
Arif Qureshi's user avatar
1 vote

How to get current category name when having only the product ID

Get category name from product anywhere. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categoryAllIds = $product->getCategoryIds(); $names = []; ...
MP Raj's user avatar
  • 502
1 vote
Accepted

How to get current category name when having only the product ID

Try the below code. I update the code as per your requirement <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $reviewData = $block->getAllRatingData(); foreach ($...
Charmi Patel's user avatar
  • 1,088
1 vote

Magento 2 Display compare block only when the number of products to compare > 0

Try moving up the <!-- ko if: compareProducts().count --> above the title. This should hide the whole block when there is no product. You might also want to remove the following block of code at ...
Cladiuss's user avatar
  • 1,261
1 vote

Filtering Product Collection on the basis of visibility

Try this To remove products from the product collection that are set as "Non-Individually Visible," you can add an additional filter to exclude those products. Assuming "Non-...
Ansari's user avatar
  • 435
1 vote

Product Gallery doesn't allow grabbing to scroll images on Mobile after upgrade

We recently upgraded from Magento 2.4.4 to 2.4.6 and have the same issue. It has been reported & confirmed at Magento GitHub: https://github.com/magento/magento2/issues/37232 The fix that worked ...
Chris Oliver's user avatar
1 vote

How create product programatically with product ProductRepository and Json

To create a product programmatically using the ProductRepository in Magento 2, you can use the following code: use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\...
Navneet Sharma's user avatar
1 vote

Magento 2.4.5 Graphql get product by category_id or uid

If my understanding is right then you want to get the products from the category. Graphql API Request to get Products from category. { categoryList(filters: {ids: {eq: "10"}}) { ...
Jitendra Patel's user avatar
1 vote
Accepted

Magento 2.4.5 Graphql get product by category_id or uid

You can still filter your category/product request by their entity ID. It's advised you now use the uid field in the category response. Docs: https://developer.adobe.com/commerce/webapi/graphql/schema/...
Liam Toohey's user avatar
1 vote

import product data programmatically using csv

Import product data programmatically using CSV- file. Step 1 : create a custom module. Example : WebbyTroops_ProductSync Step 2 : Create custom cron : Add crontab.xml file to define new cron tab, path ...
Mukesh Khatri's user avatar
1 vote

How to get the product type?

For ordered product list, from order collection we can use $item->getProductType() to get the Product type. Sample code set <?php ...... foreach ($orders->getAllItems() as $item) { echo $...
Mujahidh's user avatar
  • 2,791
1 vote

How to get disable product collection whenever flat enable at frontend

For ver 1.9.4 and above, we can disable flat table in the product collection with the helper: Mage::helper('catalog/product_flat')->disableFlatCollection(); $collection = Mage::getResourceModel('...
kiatng's user avatar
  • 694

Only top scored, non community-wiki answers of a minimum length are eligible