3 votes
Accepted

Magento2.4.2: How to create two images field in admin form?

Only the XML needs to be duplicated, and even for that only the relevant field. Just add another element of the same type, with the relevant values changed, right next to (below) this code: <...
user avatar
  • 1,156
3 votes
Accepted

Magento2.4: How to Sort Product by " Best Selling " and " Best reviewed " Product?

I don't have time to write full example and test, but play around with following logic: Bestsellers // ... public function sort(\Magento\Catalog\Model\ResourceModel\Product\Collection $...
user avatar
3 votes
Accepted

Magento2.4: How to add custom sort options in backend and sort product on storefront?

First of all, in situations when you can use plugin or observer it's always better than use preference. Your issue is related to you didn't define your sortInstances and only add options. You defined ...
user avatar
2 votes
Accepted

Error when compiling: Declaration of X must be compatible with Y

Change your function code with below as your function is not compatible with the Magento's core function. You missed the function as array : array Then run setup:di:compile command /** * Retrieve ...
user avatar
2 votes
Accepted

How to update product salable quantity in Magento 2.4 programmatically?

To set the saleable quantity of a product , you need to look at this table = "cataloginventory_stock_item" , in this the field = "qty". So in order to set the qty in this table , ...
user avatar
2 votes

Magento2.4.2: How to add product to a given position in given category?

I write small resource helper (resolver) which you can use app/code/Acme/StackExchange/Model/ResourceModel/Catalog/Product/PositionResolver.php <?php declare(strict_types=1); namespace Acme\...
user avatar
2 votes

Magento2.4: How to Sort Product by " Best Selling " and " Best reviewed " Product?

Create NameSpace\ModuleName\etc\frontend\di.xml file with current configuration: <type name="Magento\Catalog\Block\Product\ProductList\Toolbar"> <plugin name="...
user avatar
1 vote

Order Status Magento 2.4

1. Add order status app/code/Acme/StackExchange/Setup/Patch/Data/AddShippedOrderStatus.php <?php declare(strict_types=1); namespace Acme\StackExchange\Setup\Patch\Data; use Magento\Framework\...
user avatar
1 vote

Magento2.4.2: How to create two images field in admin form?

\Vendor\Module\Controller\Adminhtml\Form\TempUpload.php <?php namespace Vendor\Module\Controller\Adminhtml\Form; use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\...
user avatar
  • 288
1 vote
Accepted

Getting Customer Session null from custom module in Magento 2

Add cacheable="false" in your xml <referenceContainer name="content"> <block class="Vendor\Modulename\Block\Customer" name="customer.session.data" ...
user avatar
1 vote
Accepted

Magento2.4.2: How to create a green Enabl/Disable button in custom admin form?

You need to add a field in the schema of the custom record that your screen saves for instance: <column xsi:type="smallint" name="record_is_active" unsigned="false" ...
user avatar
1 vote
Accepted

Declaration of \Interceptor::execute() must be compatible with \Detail::execute():

Ideally since Magento 2.4.4 requires PHP 8.1 This code should work in Magento 2.4.5 Looks like you have incorrect generated cache and you just need to remove generated/code/* for developer mode or run ...
user avatar
1 vote
Accepted

Magento2.4.2: How to add product to a given position in given category?

Note: In path should be Adminhtml. I've updated some code but general goal is add logic to run reindex process Vendor\Module\Controller\Adminhtml\Import\Index.php <?php declare(strict_types=1); ...
user avatar
  • 288
1 vote

Magento2.4.2: How to add product to a given position in given category?

but issue is that when i import csv it changes the product position and displays it in last position in grid but when i debug it, it shows that product is in given position where is was supposed to be ...
user avatar
  • 288
1 vote
Accepted

Can we show Sku in shopping cart in magento 2

In your theme add a new file if it doesn't already exist: app/design/frontend/YourTheme/Magento_Checkout/templates/cart/item/default.phtml and copy the content from vendor/magento/module-checkout/view/...
user avatar
1 vote

Magento2.4.2: How to sort product by custom price attribute?

You didn't reset collection order before apply your custom order In your case you can extends from \Magento\VisualMerchandiser\Model\Sorting\AttributeAbstract and implements getSortField, ...
user avatar
1 vote

Warning: Object of class Magento\Framework\Phrase could not be converted to int product/list/toolbar/limiter.phtml on line 26

The default template looks like this: <?php foreach ($block->getAvailableLimit() as $_key => $_limit):?> <option value="<?= $block->escapeHtmlAttr($_key) ?...
user avatar
  • 196k
1 vote

Magento2.4.2: How to sort product collection by sub category as shown in this picture?

It's a really strange logic in sort method Potential issues with code are: You need to clone product collection before try to iterate it category_id will be the same for all products because it's a ...
user avatar
1 vote

Mageto2:How to Sort products by regular price?

Oh man, again question from you about the same topic and without any answers This code should work and I think here is everything is OK I just can suggest to use correlation table for price field for ...
user avatar
1 vote
Accepted

Error on compilation: Incompatible argument type: Required type: \Aheadworks\Blog\Api\CategoryManagementInterface. Actual type: array; File:

Please try below code and let me know if it works for you <?php declare(strict_types=1); namespace X\Blog\Block\Sidebar; use Aheadworks\Blog\Api\CategoryRepositoryInterface; use Aheadworks\Blog\...
user avatar
1 vote
Accepted

can not create db_schema_whitelist.json file in magento 2.4.4

Your db_schema.xml is wrong. It has duplicate entries for 'title' column. Remove it and retry. It should work. This db_schema.xml is working fine. <?xml version="1.0"?> <schema ...
user avatar
1 vote
Accepted

How to Create a Plugin after place order to change customer order email

Create di.xml app/code/Vendor/Module/etc/di.xml <type name="Magento\Quote\Observer\SubmitObserver"> <plugin name="change_customer_order_email" type="Vendor\...
user avatar
1 vote
Accepted

Magento2.4: How to sort products by Size options (XS, S , M, L ,XL)?

Just for fun I will provide one more SQL query with playing with data SELECT sl.parent_id, COUNT(sl.product_id) AS count_options, SUM(IFNULL(ss.stock_status, 0)) AS available_options, SUM(sa....
user avatar
1 vote
Accepted

How to change store based on country location in Magento244?

Create an event in: Vendor/Module/etc/frontend/events.xml <config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:framework/Event/etc/events.xsd'&...
user avatar
1 vote
Accepted

How to add Sort options in back-end grid as shown in pictures?

For implement first 2 items needs to understand Magento version, Inventory extension and usage, and also possible implement only in website scope. Without Inventory you can play with query such SELECT ...
user avatar
1 vote

Magento2.4: Display custom CMS block header and footer on homepage

You can add the static blocks in the homepage header and footer by adding the below code in your theme. <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
user avatar
  • 4,705
1 vote
Accepted

Magento2.4: Display custom CMS block header and footer on homepage

You have to override the core files in your theme or module. I'm overriding in my module have a look into this. Maybe it helps you. view/frontend/layout/cms_index_index.xml <?xml version="1....
user avatar
  • 57
1 vote
Accepted

How to set special price for specific customer group Programmatically

First you create di.xml for plugin etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=&...
user avatar
  • 57

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