0

I have two stores. View one is in English and the other is the translation, each product has the same price and information but the difference is the translation.

I want all orders in the back-end with the same items information taking in to account the fact the site/view that the item was ordered from. For example suppose I have the item with a name of name1 in first view and name2 in the second view. If the customer creates the order in first view I will see it as name1, and name2 if he creates it from the second view.

I tried to find the code that processes the checkout to change the code and set the store id to one in all cases, but I didn't find it.

Then I tried to handle it in shopping cart by changing the code _initProduct()in :

\app\code\core\Mage\Checkout\controllers\CartController.php
From
$product = Mage::getModel('catalog/product')
   ->setStoreId(Mage::app()->getStore()->getId())
   ->load($productId);
To
$product = Mage::getModel('catalog/product')
   ->setStoreId(1)
   ->load($productId);

So could you tell me please how I can do both things, changing the info of the product in the cart and order?

Edit One:

After tracing Magento code

I changed the method setProduct in class Mage_Sales_Model_Quote_Item to have this code:

$productTemp=null;
    if($product->getStoreId !== 1){
    $productTemp =  Mage::getModel('catalog/product') ->setStoreId(1)
       ->load($product->getId());
    }
    else
    {
    $productTemp=$product;
    }
    $this->setData('product', $product)
        ->setProductId($productTemp->getId())
        ->setProductType($productTemp->getTypeId())
        ->setSku($this->getProduct()->getSku())
        ->setName($productTemp->getName())
        ->setWeight($this->getProduct()->getWeight())
        ->setTaxClassId($productTemp->getTaxClassId())
        ->setBaseCost($productTemp->getCost())
        ->setIsRecurring($productTemp->getIsRecurring());

My question is, is it bad practice to edit core files & does this edit have a negative impact?

0

To get the product from different store.

I have to override the CartController located in \app\code\core\Mage\Checkout\controllers\CartController.php

edit the code store in _initProduct() to the store you want to load the product from it.

Also I have to edit the quote by editing method setProduct in class Mage_Sales_Model_Quote_Item

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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