magento2 – Unable to send the cookie with cookieName

when i execute this code after purchase with 3 products or more

$cartManagement = $objectManager->create(MagentoQuoteApiCartManagementInterface::class);
                    $orderId = $cartManagement->placeOrder($quote->getId());

or

$orderId = $this->cartManagement->placeOrder($quote->getId());

I get this error: MagentoFrameworkStdlibCookieFailureToSendException: Unable to send the cookie with cookieName = X-Magento-Vary

Increase the values in PhpCookieManager.php but the same error continues

const MAX_NUM_COOKIES = 500;
const MAX_COOKIE_SIZE = 40960;
const EXPIRE_NOW_TIME = 1;
const EXPIRE_AT_END_OF_SESSION_TIME = 0;

what is the solution?

Thanks

magento2 – How to Inject New Class to Overridden Class using Preference

I want to over __prepareLayout function from ‘MagentoSalesBlockOrderHistory’ so I used preference

in my di.xml

<preference for="MagentoSalesBlockOrderHistory" type="CustomModuleBlockOrderHistory"/>

In My History.php

class History extends MagentoSalesBlockOrderHistory
{
    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $this->setTemplate('Custom_Module::order/history.phtml');
        return $this;
    }

}

To this POint My code is working fine now I want to inject custom Helper in this class

so I added this

    public function __construct(
        CustomModuleHelperData $helper
    ) {
        $this->helper   =   $helper;
    }

After Injecting Class is Not working I have the option to use ObjectManager But It is not recommended so I preferred to Ask From Community if you have any better Option

magento2 – Magento 2 API: Extension Attribute with null value not showing

I’m retrieving from the Magento API an order by its increment_id attribute like this:

http://mystore.com/rest/V1/orders?searchCriteria(filter_groups)(0)(filters)(0)(field)=increment_id&searchCriteria(filter_groups)(0)(filters)(0)(value)=1200040527&searchCriteria(filter_groups)(0)(filters)(0)(condition_type)=eq

I have added a plugin to add a custom attribute to the Order items like this (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="MagentoSalesApiOrderRepositoryInterface">
        <plugin name="order_custom_extension_attribute"
                type="MyVendorSalesPluginOrderRepositoryPlugin"/>
    </type>
</config>

And then adding the custom attribute (is_gift_card) to the OrderItem like this (etc/extension_attributes.xml)

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="MagentoSalesApiDataOrderItemInterface">
        <attribute code="is_gift_card" type="boolean"/>
    </extension_attributes>
</config>

Finally my plugin to add the extension attribute to the order items in the afterGet and afterGetList:

    public function __construct(
         MagentoSalesApiDataOrderExtensionFactory $extensionFactory
    ) {
        $this->extensionFactory = $extensionFactory;
    }

    public function afterGet(MagentoSalesApiOrderRepositoryInterface $subject, MagentoSalesApiDataOrderInterface $order)
    {
        return $this->addExtensionAttributes($order);
    }

    public function afterGetList(MagentoSalesApiOrderRepositoryInterface $subject, MagentoSalesApiDataOrderSearchResultInterface $searchResult)
    {
        $orders = $searchResult->getItems();

        foreach ($orders as &$order) {
           $order = $this->addExtensionAttributes($order);
        }

        return $searchResult;
    }

    private function addExtensionAttributes($order){

        $items = $order->getAllItems();
        foreach ($items as $item){
            $giftCard = $item->getData('is_gift_card');
            
            $extensionAttributes = $item->getExtensionAttributes();
            $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
            $extensionAttributes->setIsGiftCard($giftCard);
            $item->setExtensionAttributes($extensionAttributes);
        }

        return $order;
    }
}

The thing is that is_gift_card is added to the extension_attribute segment IF that attribute has any value, but it is not showing at all if it has a null value.

Is this a normal behaviour from the Magento API?

Thanks in advanced

magento2 – How do I prevent empty checkout fields from being validated on page load?

I am using Magento 2.3.5 and Amasty’s “One Step Checkout” module. Amazon Pay is also present.

When viewing the checkout page, it seems something is trying to validate the <input> fields even though the user hasn’t entered anything:

enter image description here

Is this something anyone has encountered before?

magento2 – Magento 2 – Create & save customer attributes with knockout.js

In my personal checkout step I am trying to insert a form with knockout.js that allows me to create a user (if there is no login) or save some customer attributes before proceeding with the shipping address.
My code is this but it doesn’t work:

CheckSteps/BillingInfo/view/frontend/layout

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="top.search" remove="true"/>
    <referenceBlock name="header.links" remove="true"/>
    <referenceBlock name="minicart" remove="true"/>
    <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="steps" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <!-- The new step you add -->
                                        <item name="my-new-step" xsi:type="array">
                                            <item name="component" xsi:type="string">CheckSteps_BillingInfo/js/view/my-step-view</item>
                                                <!--To display step content before shipping step "sortOrder" value should be < 1-->
                                                <!--To display step content between shipping step and payment step  1 < "sortOrder" < 2 -->
                                                <!--To display step content after payment step "sortOrder" > 2 -->
                                            <item name="sortOrder" xsi:type="string">1</item>
                                            <item name="children" xsi:type="array">
                                                <!--add here child component declaration for your step-->
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
    </referenceBlock>
    <referenceBlock name="footer" remove="true"/>
</body>

CheckSteps/BillingInfo/view/frontend/web/template/mystep.html

<!--The 'billingInfo' value from the .js file should be used-->
    <form data-bind="submit: save" novalidate="novalidate">
    
        <div class="col-sm-12" style="padding:0;">
            <div class="col-sm-6" style="padding-left:0px;">
                <label for="firstname">Nome</label><input type="text" name="firstname" id="firstname" />
            </div>
            <div class="col-sm-6" style="padding-left:0px;">
                <label for="lastname">Cognome</label><input type="text" name="lastname" id="lastname" />
            </div>
            
            <div class="col-sm-6" style="padding-left:0px;">
                <label for="email">Cognome</label><input type="text" name="email" id="email" />
            </div>
            <div class="col-sm-6" style="padding-left:0px;">
                <label for="password">password</label><input type="text" name="password" id="password" />
            </div>
        
        
            <div class="col-sm-6" style="padding-left:0px;">
            <label for="codicefiscale">Codice Fiscale</label><input id="codicefiscale" name="codicefiscale" type="text" />
            </div>
            <div class="col-sm-6">
            <label for="company">Azienda</label><input id="codicefiscale" name="company" type="text" />
            </div>
            
            <div class="col-sm-6" style="padding-left:0px;">
            <label for="indirizzopec">Indirizzo PEC</label><input id="indirizzopec" name="indirizzopec" type="text" />
            </div>
            <div class="col-sm-6">
            <label for="sdi">Codice SDI</label><input id="sdi" name="sdi" type="text" />
            </div>
            
            <div class="col-sm-6" style="padding-left:0px;">
            <label for="vat_id">Partita IVA</label><input id="vat_id" name="vat_id" type="text" />
            </div>
        </div>
    
        <div class="actions-toolbar">
            <div class="primary">
                <button data-role="opc-continue" type="submit" class="button action continue primary">
                    <span><!-- ko i18n: 'Next'--><!-- /ko --></span>
                </button>
            </div>
        </div>
    </form>
</div>

CheckSteps/BillingInfo/view/frontend/web/js/view/my-step-view.js

define(
(
    'jquery',
    'ko',
    'uiComponent',
    'underscore',
    'mage/validation',
    'Magento_Checkout/js/model/step-navigator',
    'CheckSteps_BillingInfo/js/view/action/save-customer'
),
function (
    ko,
    Component,
    _,
    stepNavigator
) {
    'use strict';
    /**
    *
    * mystep - is the name of the component's .html template,
    * <Vendor>_<Module>  - is the name of the your module directory.
    *
    */
    return Component.extend({
        defaults: {
            template: 'CheckSteps_BillingInfo/mystep'
        },

        //add here your logic to display step,
        isVisible: ko.observable(true),

        /**
        *
        * @returns {*}
        */
        initialize: function () {
            this._super();
            // register your step
            stepNavigator.registerStep(
                //step code will be used as step content id in the component template
                'billingInfo',
                //step alias
                null,
                //step title value
                'Billing info',
                //observable property with logic when display step or hide step
                this.isVisible,

                _.bind(this.navigate, this),

                /**
                * sort order value
                * 'sort order value' < 10: step displays before shipping step;
                * 10 < 'sort order value' < 20 : step displays between shipping and payment step
                * 'sort order value' > 20 : step displays after payment step
                */
                9
            );

            return this;
        },

        /**
    * The navigate() method is responsible for navigation between checkout step
    * during checkout. You can add custom logic, for example some conditions
    * for switching to your custom step
    * When the user navigates to the custom step via url anchor or back button we_must show step manually here
    */
        navigate: function () {

            this.isVisible(true);
        },

        /**
        * @returns void
        */
        navigateToNextStep: function () {
            stepNavigator.next();
        },
        
        save: function (saveForm) {
            var self = this;
            var saveData = {},
                formDataArray = $(saveForm).serializeArray();

            formDataArray.forEach(function (entry) {
                saveData(entry.name) = entry.value;
            });

            if($(saveForm).validation()
                && $(saveForm).validation('isValid')
            ) {
                saveAction(saveData, totalCustomer).always(function() {
                    console.log(totalCustomer());
                });
            }
        },
        getTotalCustomer: function () {
            return totalCustomer;
        }
    });
}
);

CheckSteps/BillingInfo/view/frontend/web/js/view/action/save-customer.js

define(
(
    'ko',
    'jquery',
    'mage/storage',
    'mage/translate',
),
function (
    ko,
    $,
    storage,
    $t
) {
    'use strict';
    return function (customerData, totalCustomer) {
        return storage.post(
            'knockout/ajax/save',
            JSON.stringify(customerData),
            false
        ).done(
            function (response) {
                if (response) {
                    totalCustomer(());
                    $.each(response, function (i, v) {
                        totalCustomer.push(v);
                    });
                }
            }
        ).fail(
            function (response) {
            }
        );
    };
}

);

Unfortunately this code not save customer attributes and not save a new customer.
How can i do?

Thanks!!

magento2 – In magento 2.3.5 Swagger is not working (Failed to load API definition.)

I had upgraded the magento version to 2.3.5 after that swagger is not working in my setup

Image Reference :
enter image description here

To debug the i click invalid button it shows

{"schemaValidationMessages":({"level":"error","message":"Can't read from file http://My Domain/rest/all/schema?services=all"})}

The below errors i got in the debug.log

(2020-06-30 08:50:34) main.ERROR: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-bundle.js.map' () ()
(2020-06-30 08:50:34) main.CRITICAL: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-bundle.js.map' () ()
(2020-06-30 08:50:34) main.ERROR: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/css/swagger-ui.css.map' () ()
(2020-06-30 08:50:34) main.CRITICAL: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/css/swagger-ui.css.map' () ()
(2020-06-30 08:50:34) main.ERROR: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-standalone-preset.js.map' () ()
(2020-06-30 08:50:34) main.CRITICAL: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-standalone-preset.js.map' () ()

I ran the below commands and tested

  1. bin/magento deploy:mode:set developer – (Set the store to developer mode)
  2. Removed the pub/static frontend and adminhtml
  3. php bin/magento setup:upgrade
  4. php bin/magento setup:static-content:deploy -f
  5. php bin/magento setup:di:compile
  6. chmod -R 777 root_file/*

magento2 – Customer and Orders empty after migration 1.9.2.1 to 2.3.5-p1

Im trying to migrate data from 1.9.2.1 to 2.3.5-p1 with the data migration tools but my table customer and orders remain empty …

The errors (who became warning with -a) are :

(2020-06-30 06:11:28)(WARNING): Source fields are not mapped. Document: customer_eav_attribute. Fields: is_filterable_in_search,used_in_product_listing,store_ids,sorting_order,is_visible_on_front,type_internal,on_order_view,on_registration,is_read_only,used_in_order_grid,file_size,file_types,file_dimentions,account_filled,billing_filled,required_on_front
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: eav_attribute. Field: frontend_input. Error: Attribute with attribute_id=135 cannot contain empty field value
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: eav_attribute. Field: frontend_input. Error: Attribute with attribute_id=136 cannot contain empty field value
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: eav_attribute. Field: frontend_model. Error: Class Amasty_Customerattr_Model_Rewrite_Eav_Entity_Attribute_Frontend_Default is not mapped in record attribute_id=133
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: eav_attribute. Field: frontend_model. Error: Class Amasty_Customerattr_Model_Rewrite_Eav_Entity_Attribute_Frontend_Default is not mapped in record attribute_id=134
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: eav_attribute. Field: backend_model. Error: Class ewayrapid/backend_savedtokens is not mapped in record attribute_id=135
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: eav_attribute. Field: frontend_model. Error: Class Amasty_Customerattr_Model_Rewrite_Eav_Entity_Attribute_Frontend_Default is not mapped in record attribute_id=186
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: catalog_eav_attribute. Field: frontend_input_renderer. Error: Class benara_catalog/adminhtml_form_renderer_dimension is not mapped in record attribute_id=173
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: catalog_eav_attribute. Field: frontend_input_renderer. Error: Class benara_catalog/adminhtml_form_renderer_dimension is not mapped in record attribute_id=174
(2020-06-30 06:11:28)(WARNING): Incompatibility in data. Source document: catalog_eav_attribute. Field: frontend_input_renderer. Error: Class benara_catalog/adminhtml_form_renderer_dimension is not mapped in record attribute_id=175
(2020-06-30 06:11:28)(INFO)(mode: data)(stage: integrity check)(step: Customer Attributes Step): started
(2020-06-30 06:11:28)(INFO)(mode: data)(stage: integrity check)(step: Map Step): started
100% (============================) Remaining Time: < 1 sec
(2020-06-30 06:11:30)(WARNING): Source documents are not mapped: algoliasearch_queue,algoliasearch_queue_log,am_customerattr_guest,am_customerattr_relation,am_customerattr_relation_details,am_file,am_file_icons,am_file_stat,am_file_store,am_file_store_customer_group,am_shopby_filter,am_shopby_page,am_shopby_range,am_shopby_value,aw_blog,aw_blog_cat,aw_blog_cat_store,aw_blog_comment,aw_blog_post_cat,aw_blog_store,aw_blog_tags,bannerslider_banner,bannerslider_report,bannerslider_slider,bannerslider_value,core_directory_storage,core_file_storage,dhcarousel_group,dhcarousel_item,dhlocation_hour,dhlocation_location,dyncatprod_delaybuild,dyncatprod_rebuild,dyncatprod_subselect,mailchimp_ecommerce_sync_data,mailchimp_errors,mailchimp_sync_batches,mailchimp_webhook_request,shipping_productmatrix,smtppro_email_log,solrbridge_search_index,solrbridge_solrsearch_index_benara,solrbridge_solrsearch_logs,solrbridge_solrsearch_request,wsalogger_log
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: adminnotification_inbox. Fields: is_amasty,expiration_date
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: catalog_category_product. Fields: is_dynamic
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: eav_attribute_option. Fields: group_id
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: newsletter_subscriber. Fields: subscriber_firstname,subscriber_lastname,mailchimp_sync_delta,mailchimp_sync_error,mailchimp_sync_modified
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: sales_flat_order. Fields: ebizmarts_abandonedcart_flag,ebizmarts_magemonkey_campaign_id,eway_transaction_id,tracking,mailchimp_campaign_id,mailchimp_abandonedcart_flag,mailchimp_landing_page
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: sales_flat_order_address. Fields: mobile
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: sales_flat_order_payment. Fields: fraud_action,fraud_codes,transaction_captured,beagle_score,beagle_verification
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: sales_flat_quote. Fields: ebizmarts_abandonedcart_counter,ebizmarts_abandonedcart_flag,ebizmarts_abandonedcart_token,transaction_id,mailchimp_abandonedcart_flag,mailchimp_landing_page,mailchimp_campaign_id
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: sales_flat_quote_address. Fields: mobile
(2020-06-30 06:11:30)(WARNING): Source fields are not mapped. Document: sales_flat_quote_payment. Fields: fraud_action,fraud_codes,transaction_captured,beagle_score,beagle_verification

Anyone got a clue why ?

Thanks

magento2 – main.ERROR: The “EM0EM00284-100” product couldn’t be removed

After upgrade to Magento 2.3.5, When trying to delete products from the catalog, we receive an error. This occurs on various types of products, from virtual products, simple products, configurable products, with no relation to other products or even any data in the product itself. This is on a relatively new installation of 2.3.5.

Here’s the error message we get on the front end:

main.ERROR: The "EM0EM00284-100" product couldn't be removed. [] []

Magento2 mini cart counter not getting updated

Magento2 I am programmatiacally removing cart items.

$quoteItems = $this->checkoutSession->getQuote()->getItemsCollection();
            foreach($quoteItems as $item)
            {
                $cart->removeItem($item->getId())->save(); 
            }

My issue is mini cart counter is not getting updated

It just gets reduced by 1. Lets say if I have 3 items it will get reduced by 1 & change to 2.

I have already tried

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="inquiry/index/save">
        <section name="cart"/>
    </action>
</config>

And this

var sections = ('cart');
customerData.reload(sections, true);

cart – Magento2: How to separate quote?

Like, I have 5 items in my Cart.

It means there is 1 row in quote table. Which contains parent ID.

And, 5 rows in quote_item which describe all 5 items.

I want separate 3 items from these 5 in another custom quote and need a separate quote for these 3 items.

Expected result:

I want 2 quotes,

1 have 2 items AND 3 items will assign to the newly created quote.

Help would be appreciated.