Page 1 of 1

How to get the basket items with properties in other class

Posted: 16 May 2017, 16:58
by Starringstars
Hi,
How can I get the basket items with all their properties in another class. Separated from the vendor Laravel dir.
Not the frontend generated code but the php functions which are private or protected. Ore is there an abstract class which I can insert? :geek:

I know how to get the forntend with:
$params = app( '\Aimeos\Shop\Base\Page' )->getSections( 'basket-index' );
print_r ($params);

But need the backend ass well in php functions.

Thank you!

Re: How to get the basket items with properties in other cl

Posted: 17 May 2017, 19:16
by aimeos
Did you read this article?
https://aimeos.org/docs/Laravel/Extend_Aimeos

With the context object you can instantiate the basket controller and get the basket content:
https://github.com/aimeos/ai-controller ... end/Basket

Re: How to get the basket items with properties in other cl

Posted: 25 May 2017, 03:13
by Starringstars
Yes... Merci I've found the methods! :D

Re: How to get the basket items with properties in other cl

Posted: 15 May 2018, 08:15
by Sergunik
It's still issue for me.
Dear Support, Could you please help get basket items in own controller?

--
PHP 7.0.22-0ubuntu0.16.04.1
laravel/framework: 5.5
aimeos/ai-laravel: 2018.04.1

Re: How to get the basket items with properties in other cl

Posted: 15 May 2018, 09:34
by Sergunik
Found solution:

Code: Select all

<?php

namespace App\Helper;

class BasketHelper extends BaseHelper
{
    /**
     * @return \Aimeos\Controller\Frontend\Basket\Standard
     * @throws \Aimeos\Controller\Frontend\Exception
     * @throws \Illuminate\Container\EntryNotFoundException
     */
    private static function getBasketController()
    {
        return \Aimeos\Controller\Frontend\Factory::createController( self::getContext(), 'basket' );
    }

    /**
     * @return \Aimeos\MShop\Order\Item\Base\Product\Standard[]
     * @throws \Aimeos\Controller\Frontend\Exception
     * @throws \Illuminate\Container\EntryNotFoundException
     */
    public static function getProducts() {

        $controller = self::getBasketController();
        $summaryBasket = $controller->get();

        return $summaryBasket->getProducts();
    }
}
--
PHP 7.0.22-0ubuntu0.16.04.1
laravel/framework: 5.5
aimeos/ai-laravel: 2018.04.1

Re: How to get the basket items with properties in other cl

Posted: 27 Aug 2018, 05:09
by DiegoFelipeProaño
@Sergunik

How does your BaseHelper Class look like?

Re: How to get the basket items with properties in other cl

Posted: 22 Oct 2018, 13:01
by Sergunik
DiegoFelipeProaño wrote:How does your BaseHelper Class look like?

Code: Select all

<?php

namespace App\Helper;

class BaseHelper
{
    /**
     * @return \Aimeos\MShop\Context\Item\Standard $context
     */
    protected static function getContext() {
        return app('\Aimeos\Shop\Base\Context')->get();
    }
}