Page 1 of 1

Getting site code giving error

Posted: 11 Jan 2020, 10:29
by adityabanerjee
Hi I have extended the getSession and setSession methods from the Base.php. I have created my own php file named Ebdaa.php

my Ebdaa.php looks like

Code: Select all

<?php

namespace Aimeos\MShop\Order\Manager\Base;

class Ebdaa extends Standard
{
	public function getSession($type = 'default') 
    {	
    	$context = $this->getContext();
        $session = $context->getSession();
        $locale = $context->getLocale();
        $currency = $locale->getCurrencyId();
        $language = $locale->getLanguageId();
        $sitecode = $locale->getSiteItem()->getCode();
        $key = 'aimeos/basket/lock-' . $sitecode . '-' . $language . '-' . $currency . '-' . strval( $type );
        if( ( $value = $session->get( $key ) ) !== null ) {
            return (int) $value;
        }
        return \Aimeos\MShop\Order\Manager\Base\Base::LOCK_DISABLE;
    }	

    /**
	 * Saves the current shopping basket of the customer.
	 *
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $order Shopping basket
	 * @param string $type Order type if a customer can have more than one order at once
	 * @return \Aimeos\MShop\Order\Manager\Base\Iface Manager object for chaining method calls
	 */
    public function setSession( \Aimeos\MShop\Order\Item\Base\Iface $order, $type = 'default')
    {
    	dd('in set session');
    }	
}
Now I am facing an error-:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Aimeos\MShop\Locale\Item\Standard::getSiteItem() in file /Users/adityabanerjee/code/ebdaa-ecommerce-beta/ext/ebdaa/lib/custom/src/MShop/Order/Manager/Base/Ebdaa.php on line 14
Please assist.

Re: Getting site code giving error

Posted: 12 Jan 2020, 17:50
by aimeos
You are using the code from the master branch but your installed version is 2019.10.
The getSite() method in 2019.10 has been renamed to getSiteItem() in master.