In Magento 2.4.x, there were some changes in the constructor signatures and how collections are handled, particularly with UiComponentDataProviderSearchResult used for grids. Steps to Fix the Issue: Step 1: Update the Collection Class Your Collection class extends MagentoFrameworkViewElementUiComponentDataProviderSearchResult, which means that the constructor parameters need to match the updated signature in Magento 2.4.x. Here’s how you can update your Collection class constructor: namespace G4AMainSliderModelResourceModelMainSliderGrid;… Continue reading After Upgrade Magento version from 2.3.5 to 2.4.7, an error in the Admin Grid(Custom module) started to appear
Category: Magento
Error “Your session has expired” when click on add to cart in magento 2
when clicking on product’s add to cart then it’s giving me error–> Your session has expired. Solution UPDATE `core_config_data` SET `value` = ‘http://127.0.0.1/zain/accessories/’ WHERE `core_config_data`.`path` = ‘web/unsecure/base_url’; UPDATE `core_config_data` SET `value` = ‘http://127.0.0.1/zain/accessories/’ WHERE `core_config_data`.`path` = ‘web/secure/base_url’; http://127.0.0.1/zain/accessories/ in this write your frontend url (home page url) what you have after that run command in your… Continue reading Error “Your session has expired” when click on add to cart in magento 2
What is the use of the view.xml of theme etc directory in magento 2?
In Magento 2, the view.xml file is used to define and configure image properties such as sizes, aspect ratios, and image types for a theme. This file is located in the etc directory of a theme (app/design/frontend/{Vendor}/{theme}/etc/view.xml) and plays an important role in controlling how images are displayed across different parts of the store (e.g.,… Continue reading What is the use of the view.xml of theme etc directory in magento 2?
What is Upsell and Cross-sell in Magento 2?
What is upsell? Upsell products are items that you recommend as alternatives to the product a customer is viewing. These alternatives are usually of higher quality, more feature-rich, or more expensive. What is Cross-sell? Cross-sell products are complementary items suggested to the customer at the shopping cart stage, based on the products they have already… Continue reading What is Upsell and Cross-sell in Magento 2?
Magento 2 Change Minicart Product Image from thumbnail to regular image
We can edit view.xml in the below path app/design/{Package}/{Theme-name}/etc/view.xml add the below code in it <image id=”mini_cart_product_image” type=”image”> <width>100</width> <height>100</height> </image> you can change the image type and width/height as per your need type – It means what type of image should display in the respective places in the frontend. Explanation: image – corresponds to the… Continue reading Magento 2 Change Minicart Product Image from thumbnail to regular image
How to Get Quote_item table data ?
$objectManager = MagentoFrameworkAppObjectManager::getInstance(); $itemResourceModel = $objectManager->create(‘MagentoQuoteModelResourceModelQuoteItem’); $quoteItemFactory = $objectManager->create(‘MagentoQuoteModelQuoteItemFactory ‘); $itemId = your id here $quoteItem = $quoteItemFactory->create(); $itemResourceModel->load($quoteItem, $itemId); echo $quoteItem->getName(); echo $quoteItem->getProductId();
How to get chosen billing and shipping addresses.
$objectManager = MagentoFrameworkAppObjectManager::getInstance(); $cart = $objectManager->get(‘MagentoCheckoutModelCart’); $billingAddress = $cart->getQuote()->getBillingAddress(); echo ‘<pre>’; print_r($billingAddress->getData()); echo ‘</pre>’; $shippingAddress = $cart->getQuote()->getShippingAddress(); echo ‘<pre>’; print_r($shippingAddress->getData()); echo ‘</pre>’;
How to get all needed information in your cart?
$objectManager = MagentoFrameworkAppObjectManager::getInstance(); $cart = $objectManager->get(‘MagentoCheckoutModelCart’); // get quote items collection $itemsCollection = $cart->getQuote()->getItemsCollection(); // get array of all items what can be display directly $itemsVisible = $cart->getQuote()->getAllVisibleItems(); // get quote items array $items = $cart->getQuote()->getAllItems(); foreach($items as $item) { echo ‘ID: ‘.$item->getProductId().'<br />’; echo ‘Name: ‘.$item->getName().'<br />’; echo ‘Sku: ‘.$item->getSku().'<br />’; echo ‘Quantity: ‘.$item->getQty().'<br… Continue reading How to get all needed information in your cart?
How to get the number of items in cart and total quantity in cart?
$objectManager = MagentoFrameworkAppObjectManager::getInstance(); $cart = $objectManager->get(‘MagentoCheckoutModelCart’); $totalItems = $cart->getQuote()->getItemsCount(); $totalQuantity = $cart->getQuote()->getItemsQty();
Adding low to high and High to low
Toolrbar.php file <?php namespace JJCustomproductshowPluginCatalogBlockProductProductList; class Toolbar extends MagentoCatalogBlockProductProductListToolbar { /** * Set collection to pager * * @param MagentoFrameworkDataCollection $collection * @return MagentoCatalogBlockProductProductListToolbar */ public function afterGetAvailableOrders(Toolbar $subject, $availableOrders) { // Remove ‘position’ from available orders if it exists if (isset($availableOrders[‘position’])) { unset($availableOrders[‘position’]); } return $availableOrders; } public function setCollection($collection) { $this->_collection = $collection;… Continue reading Adding low to high and High to low