#StackBounty: #magento-2.1 #database #upgrade #magento2.2.2 Upgrading M2.1.9 to Magento 2.2.2 is very slow

Bounty: 50

We are trying to upgrade a Magento 2.1.9 site to Magento 2.2.2
We have more than 130k products and the process seems to be stuck for more than 3 hours on

Upgrading data..
Module 'Magento_Backend':
Module 'Magento_Catalog':

I used xdebug to profile what process takes so long and apparently problem is:

if (version_compare($context->getVersion(), '2.2.2') < 0) {
            $this->upgradeWebsiteAttributes->upgrade($setup);
        }

Having many products and many attributes the process takes ages. Actually it’s still stuck there so it’s been 3 days. The database size it’s 47GB


Get this bounty!!!

#StackBounty: #magento-2.1 #database #configurable-product #stock #indexing Magento2 – index modes issue

Bounty: 200

We have this Magento 2.1 project running Production mode with “Update on save” mode for all indexes

Our customer manages catalog himself, and reported us some stock issues. Problem was changing quantity for a new product was not working. Process apparently ends fine, regarding the admin message (“Product was saved ok”) but stock was not changed. We look in Magento log files, but we don’t see any related report there

Our solution, finally, was to change indexes to “Update by schedule” and then force a reindex by console command. This solution, as far as I understand, means there is something wrong with that partial reindex fired when saving a product with “Update on save” index mode. What I am asking is for a confirmation about this… should not this problem be reported in Magento log files?

Assuming there is something wrong with our catalog data, I’d like to trace the problem, so I’d like to know which processes (the complete code trace) are fired after a product save in admin, with “Update on save” index mode. In this case, I suppose catalog_inventory ones are the most relevant

Apart from that, and checking the catalog, we’ve noticed some configurable products were sharing simple products, which is rare & we are not sure if could be the origin of the problem (although we assume system wouldn’t let to do that if that’s not allowed). Maybe this could have registered some wrong data in catalog database tables, and causing the problems with partial reindex? If that’s the case… Where can I find in database which data is pending to be processed in the next full reindex process?


Get this bounty!!!

#StackBounty: #magento-2.1 #product #cart #custom-options #image How to set value of an image custom option programmatically Magento 2?

Bounty: 50

I’m trying to set a image Custom Option in a php script before adding the product to cart. Relevant code looks like this:

$specialId = 123;
$customOptions[$specialId] = "Special instruction custom option";

// $imageId = 124;
// $url = 'http://example.com/url/to/image.png';
// $customOptoins[$imageId] = $url;

$params = [
    'product' => $product_id,     //product Id
    'qty'     => $qty,            //quantity of product
    'options' => $customOptions   //custom options
];

$this->_cart->addProduct(
    $_product,
    $params
);

I’m starting with an image url as the code implies. I think I have to use MagentoFrameworkApiDataImageContentInterface, MagentoCatalogModelWebapiProductOptionTypeFileProcessor and maybe curl, but I’m unsure how to proceed.


Get this bounty!!!

#StackBounty: #magento2 #magento-2.1 #orders #edit-order Magento 2: How to edit existing Order without cancel?

Bounty: 50

I am trying to edit Order that includes the below possible cases:

  • Update Order Item Price
  • Increse Order Item Qty Or Cancel Order Item Qty
  • Add New Item into Order

For Adding new Item in Order, I am following the below Way:

$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $this->_orderFactory->load('3445');
$order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);

$quote = $objectManager->create('MagentoQuoteModelQuote')->load($order->getQuoteId());

$productId = 4272;
$productQty = 2;

$product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);

//Adding New Item into Quote
$objectManager->create('MagentoQuoteModelQuoteItem')
                ->setProduct($product)
                ->setQuote($quote)
                ->setQty($productQty)
                ->save();

//Quote Address Update
$shippingData = $order->getShippingAddress()->getData();
$quoteAddress = $quote->getShippingAddress();
$shippingData['address_id'] = $quoteAddress->getAddressId();
$quoteAddress->setData($shippingData);
$quoteAddress->save();

$billingData = $order->getBillingAddress()->getData();
$quoteAddress = $quote->getBillingAddress();
$billingData['address_id'] = $quoteAddress->getAddressId();
$quoteAddress->setData($billingData);
$quoteAddress->save();        

//Quote Collect Totals
$quote->getShippingAddress()
        ->setShippingMethod($order->getShippingMethod())
        ->setCollectShippingRates(true);
$quote->setTotalsCollectedFlag(false)->collectTotals();
$quote->save();

then I am planning to add this new Quote Item to convert into Order Item. But using the above code, All Quote Items are deleted and all grand total and subtotal in quote set to 0.

My question is: What is correct way to modify the existing Order ?

Like in sales_order_item table we have the field qty_canceled, Using the below code I can cancel the complete Item ordered qty. But when I am saving the order, Subtotal and Grand total all are set to 0.

$order = $this->_orderFactory->load('3432');
if ($order->canCancel()) {
    $orderItems = $order->getAllItems();        
    foreach ($orderItems as $item) {
        if($item['product_id']==3341) {    

            $item->setQtyCanceled($item['qty_ordered']);
            $item->save();  
        }
    }
    $order->save();
}


Get this bounty!!!

#StackBounty: #magento2 #magento-2.1 #checkout #magento2.2 #knockout Pass data to child template in cart-items of checkout page

Bounty: 100

My site is a market place site where vendors(sellers can sell their product).

Now i want to customize the to group items in cart by each vendor like this:
http://prntscr.com/hmsam6

checkout_index_index.xml

<item name="cart_groups" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart-groups</item>
<item name="children" xsi:type="array">
    <item name="cart_items" xsi:type="array">
        <item name="component" xsi:type="string">Magento_Checkout/js/view/summary/cart_groups/cart-items</item>
        <item name="children" xsi:type="array">
            <item name="details" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details</item>
                <item name="children" xsi:type="array">
                    <item name="thumbnail" xsi:type="array">
                        <item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/thumbnail</item>
                        <item name="displayArea" xsi:type="string">before_details</item>
                    </item>
                    <item name="subtotal" xsi:type="array">
                        <item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
                        <item name="displayArea" xsi:type="string">after_details</item>
                    </item>
                </item>
            </item>
        </item>
    </item>
</item>

cart-group.js

define([
'ko',
'Magento_Checkout/js/model/totals',
'uiComponent',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/quote'], function (ko, totals, Component, stepNavigator, quote) {
'use strict';

return Component.extend({
    defaults: {
        template: 'Magento_Checkout/summary/cart-groups'
    },
    groups: window.checkoutConfig.quoteItemData,
    getGroups:function(){
        var tempGroups = this.groups;
        var arr = Object.keys(tempGroups).map(function (key) { return tempGroups[key]; });

        return arr;
    },
    /**
     * Returns bool value for items block state (expanded or not)
     *
     * @returns {*|Boolean}
     */
    isItemsBlockExpanded: function () {
        return quote.isVirtual() || stepNavigator.isProcessed('shipping');
    },
    /**
     * Returns cart items qty
     *
     * @returns {Number}
     */
    getItemsQty: function () {
        return parseFloat(this.totals['items_qty']);
    },

    /**
     * Returns count of cart line items
     *
     * @returns {Number}
     */
    getCartLineItemsCount: function () {
        return parseInt(totals.getItems()().length, 10);
    },
});});

cart-group.html

1"/>

</div>

The problem is here:

            <each args="getGroups()">
            <p class="checkout-vendor-shop-name" data-bind="text: vendor_shop_name"></p>
            <!-- ko foreach: $parent.elems() -->
            <!-- ko template: getTemplate() --><!-- /ko -->
            <!-- /ko -->
        </each>

How can i pass data to child template with each data in this loop: getGroups() array. Right now it is all the data in quote, and it is duplicated 2 times


Get this bounty!!!

#StackBounty: #magento-2.1 #shopping-cart-price-rules #discount #magento-2.2.1 #magento2.2.2 Magento 2 Core Bug Found For Multiple disc…

Bounty: 50

There is core issue in all Magento 2.2.x. When we add two cart price rule with action “Percent of product price discount”. It makes little calculation issue in total discount.

For example, I have created two cart price rule:

Rule 1:

Rule Name: 10% Fix Discount
Coupon: No Coupon
Conditions: Apply for all product
Action: 
    Apply: Percent of product price discount
    Discount Amount: 10

Rule 2:

Rule Name: 5% Fix Discount
Coupon: No Coupon
Conditions: Apply for all product
Action: 
    Apply: Percent of product price discount
    Discount Amount: 5

So the calculation should be like this

For ex. Product Price = $45

First Rule(10% of product price) Discount: (45*10) / 100 = 4.5
Second Rule(5% of product price) Discount: (45*5) / 100 = 2.25

Total Discount = 6.75

But it’s shows $6.53 in total discount.

I have created issue on GitHub and magento team approved the issue. But it’s take some time time to resolve this issue.https://github.com/magento/magento2/issues/12837

Anyone have idea or any patch to resolve this issue?


Get this bounty!!!

#StackBounty: #magento2 #magento-2.1 #category #layout #product-grid Changing the layout of the product category page by editing an XML…

Bounty: 50

I am working on a Magento 2.1.7 shop. To achieve this, I have created a child-theme of Magento Blank.

On my homepage, I have enabled, from Content -> Pages -> Design, the 2 columns with right bar layout.

The 2columns-left.xml file (app/design/frontend/Company_Name/Theme_Name/Magento_Theme/page_layout/2columns-left.xml):

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>
    <referenceContainer name="columns" htmlClass="row">
        <container name="div.sidebar.main" htmlTag="div" htmlClass="hidden-xs col-sm-3" before="main">
            <container name="sidebar.main" as="sidebar_main" label="Sidebar Main"/>
            <container name="div.sidebar.additional" htmlTag="div" htmlClass="sidebar sidebar-additional2">
                <container name="sidebar.additional" as="sidebar_additional" label="Sidebar Additional"/>
            </container>
        </container>
        <referenceContainer name="main" htmlClass="col-xs-12 col-sm-9">
        </referenceContainer>
    </referenceContainer>
</layout>

The homepage source code, visible in the browser is:


In order to the same layout for the Product category pages, I went to Products -> Categories -> Design and changed the layout to columns with right bar also. I then saved and cleared the cache.

Still, the left sidebar is missing from the categories page. The source code does not contain:


Where am I wrong? As an alternative to using the admin to make this change, what layout (.xml) file shall I edit my theme (app/design/frontend/Company_Name/Theme_Name/pathToFile)?

The catalog_category_view.xml file in my theme has this code:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="columns.top">
            <referenceContainer name="category.view.container" htmlTag="div" htmlClass="category-view" remove="true">
                <block class="MagentoCatalogBlockCategoryView" name="category.image" template="Magento_Catalog::category/image.phtml"/>
                <block class="MagentoCatalogBlockCategoryView" name="category.description" template="Magento_Catalog::category/description.phtml"/>
                <block class="MagentoCatalogBlockCategoryView" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
            </referenceContainer>
        </referenceContainer>

        <referenceBlock name="page.main.title">
            <arguments>
                <argument name="id" xsi:type="string">page-title-heading</argument>
                <argument name="add_base_attribute_aria" xsi:type="string">page-title-heading toolbar-amount</argument>
            </arguments>
            <block class="MagentoCatalogBlockCategoryRssLink" name="rss.link" template="Magento_Catalog::category/rss.phtml"/>
        </referenceBlock>
    </body>
</page>

Copying the code from the homepage template to the category template does not work.

What shall I change to the code above to make it display the sidebar?


Get this bounty!!!

#StackBounty: #magento-2.1 #configurable-product #simple-product Magento2 – How to see if configurable products has simple products att…

Bounty: 50

We are using magento 2.1.9ce

And most of our products are made with an api.
There was a bug in this api connection, which disconnected simple products from the configurable product.

So now there are configurable products in our backend without any childs.
But we have 15K products in total, so to check them manually isn’t an option.

Is there a way to see which configurable products don’t have a simple product connected?


Get this bounty!!!