Skip to content
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

Removed 2 unneeded function calls. Local var is already there. #1373

Merged
merged 1 commit into from
Jan 10, 2021
Merged

Removed 2 unneeded function calls. Local var is already there. #1373

merged 1 commit into from
Jan 10, 2021

Conversation

woutersamaey
Copy link
Contributor

Removed 2 unneeded function calls. Local var is already there.

@sreichel sreichel added Component: Sales Relates to Mage_Sales enhancement labels Jan 10, 2021
@sreichel sreichel merged commit 2fe9658 into OpenMage:1.9.4.x Jan 10, 2021
@sreichel sreichel added this to the Release 19.4.10 / 20.0.6 milestone Jan 10, 2021
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
2 runs  ±0  2 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 2fe9658. ± Comparison against base commit 6270dc4.

@hannes011
Copy link

hannes011 commented Jan 18, 2021

Hi @woutersamaey @colinmollenhour @tmotyl @sreichel

I think we've to rollback this change. It appears to change and break some basic behavior of Magento on which several modules and functionalities depend on. This gets clear when you compare the two data sources $product and $this->getProduct() when dealing with configurable products!

It's quite a habit of some developers to rely on the SKU containing always the simple SKU (also if you have the quote/order item of a configurable product). Here some example stackexchange question from the community: https://magento.stackexchange.com/questions/19372/get-id-of-simple-product-of-any-configurable-product-on-cart-phtml-magento/126318

One of my customers was complaining about wrong weights and SKUs (and for some reason also wrong MPNs) on their invoices. After rolling back your changes everything was back to normal again.

Here some example data:
image

@kiatng
Copy link
Contributor

kiatng commented Jan 19, 2021

Here's the code snippet that supports @hannes011:

    /**
     * Retrieve product model object associated with item
     *
     * @return Mage_Catalog_Model_Product
     */
    public function getProduct()
    {
        $product = $this->_getData('product');
        if ($product === null && $this->getProductId()) {
            $product = Mage::getModel('catalog/product')
                ->setStoreId($this->getQuote()->getStoreId())
                ->load($this->getProductId());
            $this->setProduct($product);
        }

        /**
         * Reset product final price because it related to custom options
         */
        $product->setFinalPrice(null);
        if (is_array($this->_optionsByCode)) {
            $product->setCustomOptions($this->_optionsByCode);
        }
        return $product;
    }

That is called twice. May be a patch like this:

public function setProduct($product)
    {
        if ($this->getQuote()) {
            $product->setStoreId($this->getQuote()->getStoreId());
            $product->setCustomerGroupId($this->getQuote()->getCustomerGroupId());
        }
        $product = $this->setData('product', $product)->getProduct();
        $this
            ->setProductId($product->getId())
            ->setProductType($product->getTypeId())
            ->setSku($product->getSku())
            ->setName($product->getName())
            ->setWeight($product->getWeight())
            ->setTaxClassId($product->getTaxClassId())
            ->setBaseCost($product->getCost())
            ->setIsRecurring($product->getIsRecurring());
...

@colinmollenhour
Copy link
Member

@hannes011 does the proposed solution from @kiatng fix the issue in your case?

@hannes011
Copy link

@colinmollenhour
it works, but it's basically doing the exact same thing as before this pull request was applied. The setData is just pulled in one upwards.
I'd be fine with a rollback or that other change.
Unfortunately, version 19.4.10 was released by now so it might come to some more requests requiring this change https://github.com/OpenMage/magento-lts/releases/tag/v19.4.10 (hope not, though)

Cheers, Hannes

@sreichel
Copy link
Contributor

I'd be fine with a rollback or that other change.

Can you please provide a PR (just rollback for now)?

(I only testet with simple products ... :/ I'd prefer rollback asap too, impovements can be (re-)done later.)

@AlterWeb
Copy link
Contributor

AlterWeb commented Feb 1, 2021

Our customers also have issues with this change. I fixed this also by reverting back those lines and came here to mention the problem. A quick release of a fixed version would be preferable I guess, because this is corrupting order data while in this state.

@seansan
Copy link
Contributor

seansan commented Feb 4, 2021

@AlterWeb how did you revert this exact change? (Sorry not too familiar with git)

@AlterWeb
Copy link
Contributor

AlterWeb commented Feb 4, 2021

@seansan The most easy way is to copy app/code/core/Mage/Sales/Model/Quote/Item.php to app/code/local/Mage/Sales/Model/Quote/Item.php. This way the core file stays intact but Magento is using the local version. In the local file you then change $product->getSku() back to $this->getProduct()->getSku() and $product->getWeight() back to $this->getProduct()->getWeight().

Don't forget to remove this local copy after you update OpenMage to a newer version where this issue is resolved (it looks like it will be fixed in 19.4.11 when it will be released).

@addison74
Copy link
Contributor

After reading how many issues created this commit a famous phrase is coming in my mind: if it ain't broke, don't fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Sales Relates to Mage_Sales enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants