1

I've recently started using PayPal as an alternative option for customers and I noticed that on the PayPal site that the products SKU is being displayed. For continuity of my website, I would like to display the product ID instead.

I have done searches with grep in /app/code/core/Mage/Paypal to find getSku but cant find anything.

Where does the Magento PayPal module get the product SKU? and How can I replace it with the ID? ($_product->getId()) ?

3
  • Pls go file \app\code\core\Mage\Paypal\Model\Cart.php and find $salesItem->getSku()
    – Abdul
    Dec 19, 2016 at 11:27
  • 1
    Post as an answer I will test later thank you
    – SR_Magento
    Dec 19, 2016 at 11:35
  • I put getId but it generates a number other than the product ID.
    – SR_Magento
    Dec 19, 2016 at 15:49

1 Answer 1

1

First move file app\code\core\Mage\Paypal\Model\Cart.php in local folder or override model in local

After replace code from

protected function _addRegularItem(Varien_Object $salesItem)
{
    if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
        $qty = (int) $salesItem->getQtyOrdered();
        $amount = (float) $salesItem->getBasePrice();
        // TODO: nominal item for order
    } else {
        $qty = (int) $salesItem->getTotalQty();
        $amount = $salesItem->isNominal() ? 0 : (float) $salesItem->getBaseCalculationPrice();
    }
    // workaround in case if item subtotal precision is not compatible with PayPal (.2)
    $subAggregatedLabel = '';
    if ($amount - round($amount, 2)) {
        $amount = $amount * $qty;
        $subAggregatedLabel = ' x' . $qty;
        $qty = 1;
    }

    // aggregate item price if item qty * price does not match row total
    if (($amount * $qty) != $salesItem->getBaseRowTotal()) {
        $amount = (float) $salesItem->getBaseRowTotal();
        $subAggregatedLabel = ' x' . $qty;
        $qty = 1;
    }

    return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
}  

To

protected function _addRegularItem(Varien_Object $salesItem)
{
    if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
        $qty = (int) $salesItem->getQtyOrdered();
        $amount = (float) $salesItem->getBasePrice();
        // TODO: nominal item for order
    } else {
        $qty = (int) $salesItem->getTotalQty();
        $amount = $salesItem->isNominal() ? 0 : (float) $salesItem->getBaseCalculationPrice();
    }
    // workaround in case if item subtotal precision is not compatible with PayPal (.2)
    $subAggregatedLabel = '';
    if ($amount - round($amount, 2)) {
        $amount = $amount * $qty;
        $subAggregatedLabel = ' x' . $qty;
        $qty = 1;
    }

    // aggregate item price if item qty * price does not match row total
    if (($amount * $qty) != $salesItem->getBaseRowTotal()) {
        $amount = (float) $salesItem->getBaseRowTotal();
        $subAggregatedLabel = ' x' . $qty;
        $qty = 1;
    }

    return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getProductId());
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.