How to get the basket items with properties in other class

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Starringstars
Posts: 2
Joined: 16 May 2017, 16:40

How to get the basket items with properties in other class

Post by Starringstars » 16 May 2017, 16:58

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!

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

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

Post by aimeos » 17 May 2017, 19:16

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Starringstars
Posts: 2
Joined: 16 May 2017, 16:40

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

Post by Starringstars » 25 May 2017, 03:13

Yes... Merci I've found the methods! :D

Sergunik
Posts: 12
Joined: 16 Mar 2018, 14:14

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

Post by Sergunik » 15 May 2018, 08:15

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

Sergunik
Posts: 12
Joined: 16 Mar 2018, 14:14

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

Post by Sergunik » 15 May 2018, 09:34

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

DiegoFelipeProaño
Posts: 1
Joined: 27 Aug 2018, 05:07

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

Post by DiegoFelipeProaño » 27 Aug 2018, 05:09

@Sergunik

How does your BaseHelper Class look like?

Sergunik
Posts: 12
Joined: 16 Mar 2018, 14:14

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

Post by Sergunik » 22 Oct 2018, 13:01

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();
    }
}

Post Reply