Skip to content

Multishipping Checkout Store id is saved NULL in sales_order_item Table: FIXED #19321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions app/code/Magento/Quote/Model/Quote/Address/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Magento\Quote\Model\Quote;

/**
* Quote item model.
*
* @api
* @method int getParentItemId()
* @method \Magento\Quote\Model\Quote\Address\Item setParentItemId(int $value)
Expand Down Expand Up @@ -46,6 +48,8 @@
* @method \Magento\Quote\Model\Quote\Address\Item setSuperProductId(int $value)
* @method int getParentProductId()
* @method \Magento\Quote\Model\Quote\Address\Item setParentProductId(int $value)
* @method int getStoreId()
* @method \Magento\Quote\Model\Quote\Address\Item setStoreId(int $value)
* @method string getSku()
* @method \Magento\Quote\Model\Quote\Address\Item setSku(string $value)
* @method string getImage()
Expand Down Expand Up @@ -101,15 +105,15 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem
protected $_quote;

/**
* @return void
* @inheritdoc
*/
protected function _construct()
{
$this->_init(\Magento\Quote\Model\ResourceModel\Quote\Address\Item::class);
}

/**
* @return $this|\Magento\Quote\Model\Quote\Item\AbstractItem
* @inheritdoc
*/
public function beforeSave()
{
Expand Down Expand Up @@ -154,6 +158,8 @@ public function getQuote()
}

/**
* Import quote item.
*
* @param \Magento\Quote\Model\Quote\Item $quoteItem
* @return $this
*/
Expand All @@ -168,6 +174,8 @@ public function importQuoteItem(\Magento\Quote\Model\Quote\Item $quoteItem)
$quoteItem->getProductId()
)->setProduct(
$quoteItem->getProduct()
)->setStoreId(
$quoteItem->getStoreId()
)->setSku(
$quoteItem->getSku()
)->setName(
Expand All @@ -190,10 +198,9 @@ public function importQuoteItem(\Magento\Quote\Model\Quote\Item $quoteItem)
}

/**
* @param string $code
* @return \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface|null
* @inheritdoc
*/
public function getOptionBycode($code)
public function getOptionByCode($code)
{
if ($this->getQuoteItem()) {
return $this->getQuoteItem()->getOptionBycode($code);
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Quote/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@
comment="Super Product Id"/>
<column xsi:type="int" name="parent_product_id" padding="10" unsigned="true" nullable="true" identity="false"
comment="Parent Product Id"/>
<column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="true" identity="false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we can't add a foreign key to store table due to Split database performance solution. This solution provides an ability to move quote related tables to a separate database and with current changes, we will have the fatal error due to missing table.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sidolov , foreign key removed

comment="Store Id"/>
<column xsi:type="varchar" name="sku" nullable="true" length="255" comment="Sku"/>
<column xsi:type="varchar" name="image" nullable="true" length="255" comment="Image"/>
<column xsi:type="varchar" name="name" nullable="true" length="255" comment="Name"/>
Expand Down Expand Up @@ -403,6 +405,9 @@
<index referenceId="QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID" indexType="btree">
<column name="quote_item_id"/>
</index>
<index referenceId="QUOTE_ADDRESS_ITEM_STORE_ID" indexType="btree">
<column name="store_id"/>
</index>
</table>
<table name="quote_item_option" resource="checkout" engine="innodb" comment="Sales Flat Quote Item Option">
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="true"
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Quote/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"product_id": true,
"super_product_id": true,
"parent_product_id": true,
"store_id": true,
"sku": true,
"image": true,
"name": true,
Expand All @@ -233,7 +234,8 @@
"index": {
"QUOTE_ADDRESS_ITEM_QUOTE_ADDRESS_ID": true,
"QUOTE_ADDRESS_ITEM_PARENT_ITEM_ID": true,
"QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID": true
"QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID": true,
"QUOTE_ADDRESS_ITEM_STORE_ID": true
},
"constraint": {
"PRIMARY": true,
Expand Down