Help with orders list

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
rud99
Posts: 10
Joined: 21 Mar 2022, 10:38

Help with orders list

Post by rud99 » 28 Mar 2022, 11:36

Hello!
I watn to use my orders data from "mshop_order" table in updateAsync() method.
I saw https://aimeos.org/docs/latest/models/m ... er-methods , but i can not apply it in my case.
I did so in my custom payment provider:

Code: Select all

$context = $this->getContext();
$manager = \Aimeos\MShop::create( $context, 'order' );
$filter = $manager->filter(true);
$filter->add( 'id', '==', 73 );
$items = $manager->search($filter, ['order']);
I did not get results.

Thanks!

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

Re: Help with orders list

Post by aimeos » 29 Mar 2022, 08:43

"id" is not a valid search key, but "order.id" would be.

There are also methods available in service providers which simplifies retrieving data:
https://aimeos.org/docs/latest/provider ... order-item
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rud99
Posts: 10
Joined: 21 Mar 2022, 10:38

Re: Help with orders list

Post by rud99 » 29 Mar 2022, 13:01

I solved my problem with orders list, but I have new ). This code change my "order.statuspayment" in order object, but I have problem with $this->saveOrder($order); in method. It construction interupt scrip

Code: Select all

    public function updateAsync() : bool
    {
        $manager = \Aimeos\MShop::create($this->getContext(), 'order' );
        $search = $manager->filter(true);

        $expr = [
            $search->compare( '==', 'order.statuspayment', [
                \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED,
                \Aimeos\MShop\Order\Item\Base::PAY_PENDING,
                \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED] ),
            $search->compare( '!=', 'order.transaction_id', null),
        ];
        $search->setConditions( $search->and( $expr ) );

        $items = $manager->search( $search );

        if ($items) {
            foreach ($items as $item) {
                $transactionId = $item->get('transaction_id');
                dump($transactionId);
                $response = ***get bank response ****;
                $status = $this->statuses[$response->status];
                $order = $this->getOrder($item->getId());
                $order->setStatusPayment($status);
                $this->saveOrder($order);
            }
        }

        return true;
    }
I have new status in order after $order->setStatusPayment($status), but I have a new firld ".statuspayment" in order with old statuspayment value. Old status = 4. New status = 2.
https://disk.yandex.ru/i/LkqgkYrrEhgKHw

rud99
Posts: 10
Joined: 21 Mar 2022, 10:38

Re: Help with orders list

Post by rud99 » 30 Mar 2022, 11:06

I solved problem. Problem was in my Decorator

Code: Select all

    private $attr = [
        'order.transaction_id' => [
            'code' => 'order.transaction_id',
            'internalcode' => 'mord."transaction_id"',
            'label' => 'Bank transaction Id',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
    ];
I deleted "order."

Code: Select all

    private $attr = [
        'transaction_id' => [
            'code' => 'transaction_id',
            'internalcode' => 'mord."transaction_id"',
            'label' => 'Bank transaction Id',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
    ];

Post Reply