Magento Добавляет товар в корзину программно - Работает на одном веб-сайте, не работает на другом


У меня есть магазин magento с двумя сайтами для итальянского и испанского рынков. Я выполняю php-страницу для программного добавления товаров в корзину, но она работает в Испании, но не в Италии.

Смотрите пример кода, который работает на ES, но не в НЕМ.

umask(0);
Mage::app();
$session = Mage::getSingleton('core/session', array('name' =>> 'frontend')); 
$cart = Mage::getSingleton('checkout/cart');
$cart->init();
$cart->addProduct(140616, 3);
$session->setCartWasUpdated(true);
$cart->save(); 

В var_dump после $cart->init(); я вижу, что корзина в НЕМ не загружает данные о клиентах.

var_dump в ES

object(Mage_Checkout_Model_Cart)[80]
  protected '_summaryQty' => null
  protected '_productIds' => null
  protected '_data' => 
    array (size=1)
      'quote' => 
        object(Mage_Sales_Model_Quote)[82]
          protected '_eventPrefix' => string 'sales_quote' (length=11)
          protected '_eventObject' => string 'quote' (length=5)
          protected '_customer' =>
            object(Mage_Customer_Model_Customer)[136]
              protected '_eventPrefix' => string 'customer' (length=8)
              protected '_eventObject' => string 'customer' (length=8)
              protected '_errors' => 
                array (size=0)
                  empty
              protected '_attributes' => null
              protected '_addresses' => null
              protected '_addressesCollection' => null

VAR_DUMP в НЕМ

object(Mage_Checkout_Model_Cart)[81]
  protected '_summaryQty' => null
  protected '_productIds' => null
  protected '_data' => 
    array (size=1)
      'quote' => 
        object(Mage_Sales_Model_Quote)[83]
          protected '_eventPrefix' => string 'sales_quote' (length=11)
          protected '_eventObject' => string 'quote' (length=5)
          protected '_customer' => null
          protected '_addresses' => null
          protected '_items' => 
            object(Mage_Sales_Model_Resource_Quote_Item_Collection)[136]
              protected '_quote' => 
                &object(Mage_Sales_Model_Quote)[83]
              protected '_productIds' => 
                array (size=11)
                  0 => int 139190
                  1 => int 139167
                  2 => int 73844

Есть какие-нибудь сладости?

Спасибо

Author: jfrubio, 2015-09-09

1 answers

Согласно комментарию as. Вам необходимо инициализировать Mage::app() для каждого магазина.

ТАК что просто нужно добавить магазин в Mage::app().

Использовать: Mage::app("StoreCOde",'Storetype');

Вместо Mage::app()

 1
Author: Amit Bera, 2020-06-15 08:30:17