Set product default shipping restrictions

I need all countries to be restricted from shipping. If I select a country in the restricted shipping section I need that country to be able to ship. Currently Magneto does the opposite.

Does anyone know what I would override to reverse the logic?

enter image description here

Seperate descriptions for catalog page and product page

I was using the martfury theme for my site before and they had separate fields for the shop page description and product page description. I’ve since changed themes and it only shows a section for short product description. Could somebody please tell me how martfury was able to implement this? I’ve attached a screenshot to show what I mean. Thanks so much!

enter image description here

fa.functional analysis – Is a specific product function orthogonal to all harmonic functions

Suppose $Omega=(-1,1)^3$. Let $f:(-1,1)to mathbb R$ and $g:(-1,1)^2to mathbb R$ be smooth functions and suppose that given any harmonic function on $Omega$ (i.e. $Delta u =0$ on $Omega$), with $u in L^2(Omega)$, there holds:
$$ int_{Omega} u(x^1,x^2,x^2) f(x^1)g(x^2,x^3),dx=0.$$

Does it follow that $f$ and $g$ are identically zero?

magento2.3 – Save Product custom filed data to sales_order_item table custom field from in Magento 2

I have created custom column in sales_order_item table, I am trying to save product custom field data to sales_order_item custom filed. But I am unable to save.

tried the way to create field as below:

<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="sales_order_item" resource="sales" engine="innodb" comment="Sales Order Item">
        <column xsi:type="varchar" name="custom_message"   nullable="true" comment="Custom Message"/>
    </table>
</schema>

Any suggestions to do?

How to get SQL query for product insert in Magento 2?

How to get SQL query for product insert in Magento 2 ?

I have multiple products around 10 Lakhs so i want to insert it using SQL query.

But how will i get the insert query of the product ?

Any Help is Appreciated.

What is sequential boundary of a $delta$-hyperbolic space and how is the Gromov product extended to the boundary?

I have been reading up on $delta$-hyperbolic spaces. But I am not getting a clear idea of sequential boundary of $delta$-hyperbolic spaces and how the Gromov product is extended to it. Could somebody please explain it to me?

magento2 – How to check if a product is in stock or out stock?

I am trying to override this controller magentomodule-salesControllerAbstractControllerReorder.php and would like to add an if statement to check if a product is still in stock or no.

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace MagentoSalesControllerAbstractController;

use MagentoFrameworkAppAction;
use MagentoFrameworkRegistry;
use MagentoFrameworkAppActionHttpPostActionInterface;

/**
 * Abstract class for controllers Reorder(Customer) and Reorder(Guest)
 *
 * @package MagentoSalesControllerAbstractController
 */
abstract class Reorder extends ActionAction implements HttpPostActionInterface
{
    /**
     * @var MagentoSalesControllerAbstractControllerOrderLoaderInterface
     */
    protected $orderLoader;

    /**
     * @var Registry
     */
    protected $_coreRegistry;

    /**
     * @param ActionContext $context
     * @param OrderLoaderInterface $orderLoader
     * @param Registry $registry
     */
    public function __construct(
        ActionContext $context,
        OrderLoaderInterface $orderLoader,
        Registry $registry
    ) {
        $this->orderLoader = $orderLoader;
        $this->_coreRegistry = $registry;
        parent::__construct($context);
    }

    /**
     * Action for reorder
     *
     * @return MagentoFrameworkControllerResultInterface
     */
    public function execute()
    {
        $result = $this->orderLoader->load($this->_request);
        if ($result instanceof MagentoFrameworkControllerResultInterface) {
            return $result;
        }
        $order = $this->_coreRegistry->registry('current_order');
        /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        /* @var $cart MagentoCheckoutModelCart */
        $cart = $this->_objectManager->get(MagentoCheckoutModelCart::class);
        $items = $order->getItemsCollection();
        foreach ($items as $item) {
            try {
                $cart->addOrderItem($item);
            } catch (MagentoFrameworkExceptionLocalizedException $e) {
                if ($this->_objectManager->get(MagentoCheckoutModelSession::class)->getUseNotice(true)) {
                    $this->messageManager->addNoticeMessage($e->getMessage());
                } else {
                    $this->messageManager->addErrorMessage($e->getMessage());
                }
                return $resultRedirect->setPath('*/*/history');
            } catch (Exception $e) {
                $this->messageManager->addExceptionMessage(
                    $e,
                    __('We can't add this item to your shopping cart right now.')
                );
                return $resultRedirect->setPath('checkout/cart');
            }
        }

        $cart->save();
        return $resultRedirect->setPath('checkout/cart');
    }
}

this is the line that I want to add the if statement – basically inside the foreach item function.

foreach ($items as $item) {
            try {
                $cart->addOrderItem($item);
            } catch (MagentoFrameworkExceptionLocalizedException $e) {
                if ($this->_objectManager->get(MagentoCheckoutModelSession::class)->getUseNotice(true)) {
                    $this->messageManager->addNoticeMessage($e->getMessage());
                } else {
                    $this->messageManager->addErrorMessage($e->getMessage());
                }
                return $resultRedirect->setPath('*/*/history');
            } catch (Exception $e) {
                $this->messageManager->addExceptionMessage(
                    $e,
                    __('We can't add this item to your shopping cart right now.')
                );
                return $resultRedirect->setPath('checkout/cart');
            }
        }

What I did:

/**
     * @var MagentoSalesControllerAbstractControllerOrderLoaderInterface
     */
    protected $orderLoader;

    /**
     * @var Registry
     */
    protected $_coreRegistry;

    protected $_stockItemRepository;

    /**
     * @param ActionContext $context
     * @param OrderLoaderInterface $orderLoader
     * @param Registry $registry
     */
    public function __construct(
        ActionContext $context,
        OrderLoaderInterface $orderLoader,
        Registry $registry,
        MagentoCatalogInventoryModelStockStockItemRepository $stockItemRepository
    ) {
        $this->orderLoader = $orderLoader;
        $this->_coreRegistry = $registry;
        $this->_stockItemRepository = $stockItemRepository;
        parent::__construct($context, $orderLoader, $registry);
    }

    /**
     * Action for reorder
     *
     * @return MagentoFrameworkControllerResultInterface
     */
    public function execute()
    {
        $result = $this->orderLoader->load($this->_request);
        if ($result instanceof MagentoFrameworkControllerResultInterface) {
            return $result;
        }
        $order = $this->_coreRegistry->registry('current_order');
        /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        /* @var $cart MagentoCheckoutModelCart */
        $cart = $this->_objectManager->get(MagentoCheckoutModelCart::class);
        $items = $order->getItemsCollection();
        foreach ($items as $item) {
             $_productStock = $this->_stockItemRepository->get($item->getProductId());
             if($_productStock->getIsInStock()) {
            try {
                
                $cart->addOrderItem($item);
    
            } catch (MagentoFrameworkExceptionLocalizedException $e) {
                if ($this->_objectManager->get(MagentoCheckoutModelSession::class)->getUseNotice(true)) {
                    $this->messageManager->addNoticeMessage($e->getMessage());
                } else {
                    $this->messageManager->addErrorMessage($e->getMessage());
                }
                return $resultRedirect->setPath('*/*/history');
            } catch (Exception $e) {
                $this->messageManager->addExceptionMessage(
                    $e,
                    __('We can't add this item to your shopping cart right now.')
                );
                return $resultRedirect->setPath('checkout/cart');
            }
    }
        }

        $cart->save();
        return $resultRedirect->setPath('checkout/cart');
    }

I got this error Type Error occurred when creating object: MagentoSalesControllerOrderReorderInterceptor I think it’s because of MagentoCatalogInventoryModelStockStockItemRepository $stockItemRepository contruct

This is a controller for reorder – It keeps on giving me an error, I’m wondering if my code looks correct or no? is there a better a way to do this?

magento2 – Magento 2 Add Custom Image Uploader in Admin Product Edit Form

I am struggling with strange and very common issue with Custom Image Uploader in Admin. I just need to add a custom image uploader in the Product add/edit form and to save the particular image respective to that product as custom attribute. But, When i am trying to upload the file it always gives error “The file was not uploaded.”. Here is my code.

VendorModuleetcadminhtmlroutes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="Custom" frontName="Custom">
            <module name="Vendor_Module" before="Magento_Backend" />
        </route>
    </router>
</config>

VendorModuleviewadminhtmlui_componentproduct_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
   <fieldset name="magenest">
       <argument name="data" xsi:type="array">
           <item name="config" xsi:type="array">
               <item name="label" xsi:type="string">Specification Image</item>
               <item name="collapsible" xsi:type="boolean">true</item>
               <item name="dataScope" xsi:type="string">data.magenest</item>
               <item name="sortOrder" xsi:type="number">10</item>
           </item>
       </argument>
<field name="specification_image">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">string</item>
                    <item name="source" xsi:type="string">product</item>
                    <item name="label" xsi:type="string" translate="true">Specification Image</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="formElement" xsi:type="string">fileUploader</item>
                    <item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
                    <item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
                    <item name="required" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">40</item>
                    <item name="uploaderConfig" xsi:type="array">
                        <item name="url" xsi:type="url" path="Custom/product_image/upload"/>
                    </item>
                </item>
            </argument>
        </field>
   </fieldset>
</form>

VendorModuleSetupUpgradeData.php

use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavSetupEavSetupFactory;
use MagentoCatalogModelProduct;
use MagentoEavModelEntityAttributeScopedAttributeInterface;


class UpgradeData implements UpgradeDataInterface
{

    /**
     * @var eavSetup
     */
    private $eavSetup;
    
    public function __construct(
        EavSetupFactory $eavSetupFactory        
    ) {
        $this->eavSetupFactory = $eavSetupFactory;        
    }

    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $this->eavSetup = $this->eavSetupFactory->create(('setup' => $setup));
        if (version_compare($context->getVersion(), '1.0.1') < 0) {
           
            $this->addProductImageAttribute();
        }
    }

    public function addProductImageAttribute()
    {
        $this->eavSetup->addAttribute(
            Product::ENTITY,
            'specification_image',
            (
                'type'         => 'varchar',
                'backend'      => '',
                'frontend'     => '',
                'label'        => 'Specification Image',
                'input'        => 'image',
                'global'       => ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible'      => true,
                'required'     => false,
                'user_defined' => true,
                'default'      => '',
                'searchable'   => false,
                'filterable'   => false,
                'comparable'   => false,
                'unique'       => false,
                'visible_on_front' => true,
                'used_in_product_listing' => true,
                'group'        => 'General Information'
            )
        );
    }
}

VendorModuleetcdi.xml

<type name="FfcCatalogControllerAdminhtmlProductImageUpload">
    <arguments>
        <argument name="imageUploader" xsi:type="object">MagentoCatalogProductImageUpload</argument>
    </arguments>
</type>

<virtualType name="MagentoCatalogProductImageUpload" type="MagentoCatalogModelImageUploader">
    <arguments>
        <argument name="baseTmpPath" xsi:type="string">catalog/tmp/product</argument>
        <argument name="basePath" xsi:type="string">catalog/product</argument>
        <argument name="allowedExtensions" xsi:type="array">
            <item name="jpg" xsi:type="string">jpg</item>
            <item name="jpeg" xsi:type="string">jpeg</item>
            <item name="gif" xsi:type="string">gif</item>
            <item name="png" xsi:type="string">png</item>
        </argument>
        <argument name="allowedMimeTypes" xsi:type="array">
            <item name="jpg" xsi:type="string">image/jpg</item>
            <item name="jpeg" xsi:type="string">image/jpeg</item>
            <item name="gif" xsi:type="string">image/gif</item>
            <item name="png" xsi:type="string">image/png</item>
        </argument>
    </arguments>
</virtualType>    
</config>

VendorModuleControllerAdminhtmlProductImageUpload.php

<?php        

use MagentoFrameworkControllerResultFactory;
    
class Upload extends MagentoBackendAppAction
{
    
    protected $imageUploader;    
    
    private $uploaderFactory;
    
    protected $mediaDirectory;
        
    protected $storeManager;
        
    protected $coreFileStorageDatabase;
        
    protected $logger;

    protected $imageUploaders;
        
    public function __construct(
        MagentoBackendAppActionContext $context,
        MagentoCatalogModelImageUploader $imageUploader,
        MagentoMediaStorageModelFileUploaderFactory $uploaderFactory,
        MagentoFrameworkFilesystem $filesystem,
        MagentoStoreModelStoreManagerInterface $storeManager,
        MagentoMediaStorageHelperFileStorageDatabase $coreFileStorageDatabase,
        PsrLogLoggerInterface $logger            
    ) {
        parent::__construct($context);
        $this->imageUploader = $imageUploader;
        $this->uploaderFactory = $uploaderFactory;
        $this->mediaDirectory = $filesystem->getDirectoryWrite(MagentoFrameworkAppFilesystemDirectoryList::MEDIA);
        $this->storeManager = $storeManager;
        $this->coreFileStorageDatabase = $coreFileStorageDatabase;
        $this->logger = $logger;            
    }

    
    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed('Vendor_Module::product');
    }
        
    public function execute()
    {
        try {            
            $result = $this->imageUploader->saveFileToTmpDir('specification_image');                
            $result('cookie') = (
                'name' => $this->_getSession()->getName(),
                'value' => $this->_getSession()->getSessionId(),
                'lifetime' => $this->_getSession()->getCookieLifetime(),
                'path' => $this->_getSession()->getCookiePath(),
                'domain' => $this->_getSession()->getCookieDomain(),
            );            
        } catch (Exception $e) {
            $result = ('error' => $e->getMessage(), 'errorcode' => $e->getCode());
        }
        return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
    }
}

I didn’t find anything in the error log. I tried every possible way to find the root cause of the problem but couldn’t. I thought this problem might be due to not available of the MIME type. So i added “allowedMimeTypes” argument in di.xml but that also didn’t work out.

I followed the same way to add custom Image Uploader in Admin Category Edit Form and It’s working perfectly without any problem. But I don’t know why it’s not working with Product. Apart from solving this issue, please also guide me how to save this image with product as it’s custom attribute value in database.

I appreciate every help possible. Thank you!

Need help with configurable product

I have created a configurable product in my store following the Magento official tutorial.
After creating the product, on the website, on the product page the following info appears:

enter image description here

What can I do to make disappear the “+65,50 RON” value next to the quantity of the product?
The Ambalaj attribute is referring to quantity and RON is the currency in my country.

Thank you!

magento2 – On updating product using ASYNC REST API it doesn’t create product in Magento 2

I have using postman to test API to create a product

API URL : http://127.0.0.1/magento/rest/async/V1/products

Data Passed to test same as documentation :

{
 "product": {
"sku": "MS-Champ-S",
"name": "Champ Tee Small",
"attribute_set_id": 9,
"price": 25,
"status": 1,
"visibility": 1,
"type_id": "simple",
"weight": "0.5",
"extension_attributes": {
    "category_links": (
        {
            "position": 0,
            "category_id": "11"
        },
        {
            "position": 1,
            "category_id": "12"
        },
        {
            "position": 2,
            "category_id": "16"
        }
    ),
    "stock_item": {
        "qty": "10",
        "is_in_stock": true
    }
},
"custom_attributes": (
    {
        "attribute_code": "description",
        "value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
    },
    {
        "attribute_code": "tax_class_id",
        "value": "2"
    },
    {
        "attribute_code": "material",
        "value": "148"
    },
    {
        "attribute_code": "pattern",
        "value": "196"
    },
    {
        "attribute_code": "color",
        "value": "52"
    },
    {
        "attribute_code": "size",
        "value": "168"
    }
)
}
}

Gets response in postman

{
"bulk_uuid": "412bbfea-c6c9-4bce-8c27-84be8be790c6",
"request_items": (
    {
        "id": 0,
        "data_hash": "df9eef8c84da301b911a57b247d0dd8776556a2e921374db9dece5a9747377aa",
        "status": "accepted"
    }
),
"errors": false
}

When i go to admin to check the product it doesn’t create any product.

Shows this at the top

Task "Topic async.magento.catalog.api.productrepositoryinterface.save.post": 1 item(s) are currently being updated.1 item(s) have been scheduled for update.

enter image description here

Any one helped me what i have missed ?
Any help is appeiciated.