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)
#3363 by brunojti
06 Sep 2016, 17:27
Now my Item class looks like this:

Code: Select all<?php

/**
 * @copyright Metaways Infosystems GmbH, 2011
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
 * @copyright Aimeos (aimeos.org), 2015
 * @package MShop
 * @subpackage Common
 */

namespace Aimeos\MShop\Order\Item\Base\Address;

class MarchioAddressItem extends \Aimeos\MShop\Order\Item\Base\Address\Standard
    implements \Aimeos\MShop\Order\Item\Base\Address\Iface
{

    private $prefix;

    public function __construct(array $values = array())
    {
        parent::__construct($values);

        $this->prefix = 'order.base.address.';
    }

    public function fromArray(array $list)
    {
        $unknown = array();
        $list = parent::fromArray($list);

        foreach ($list as $key => $value) {
            switch ($key) {
                case 'order.base.address.address4':
                    $this->setAddress4($value);
                    break;
                case 'order.base.address.areacode':
                    $this->setAreaCode($value);
                    break;
                default:
                    $unknown[$key] = $value;
            }
        }

        return $unknown;
    }

    public function toArray()
    {
        $list = parent::toArray();

        $list['order.base.address.address4'] = $this->getAddress4();
        $list['order.base.address.areacode'] = $this->getAreaCode();

        return $list;
    }


    public function getAddress4()
    {
        if (isset($this->values['order.base.address.address4'])) {
            return (string)$this->values['order.base.address.address4'];
        }

        return '';
    }

    public function setAddress4($value)
    {
        if ($value == $this->getAddress4()) {
            return $this;
        }

        $this->values['order.base.address.address4'] = $value;
        $this->setModified();

        return $this;
    }

    public function getAreaCode()
    {
        if (isset($this->values['order.base.address.areacode'])) {
            return (string)$this->values['order.base.address.areacode'];
        }

        return '';
    }

    public function setAreaCode($value)
    {
        if ($value == $this->getAreaCode()) {
            return $this;
        }

        $this->values['order.base.address.areacode'] = $value;
        $this->setModified();

        return $this;
    }
}


And this is what the $address object looks like before the call to $address->setId(null);

Code: Select allAimeos\MShop\Order\Item\Base\Address\MarchioAddressItem Object
(
    [prefix:Aimeos\MShop\Order\Item\Base\Address\MarchioAddressItem:private] => order.base.address.
    [values:Aimeos\MShop\Order\Item\Base\Address\Standard:private] => Array
        (
            [order.base.address.siteid] => 1
            [order.base.address.type] => payment
        )

    [modified:Aimeos\MShop\Common\Item\Base:private] => 1
    [prefix:Aimeos\MShop\Common\Item\Address\Base:private] => order.base.address.
    [values:Aimeos\MShop\Common\Item\Address\Base:private] => Array
        (
            [order.base.address.siteid] => 1
            [order.base.address.firstname] => Bruno
            [order.base.address.lastname] => Rodrigues
            [order.base.address.vatid] => 12312312312
            [order.base.address.address1] => Rua 20, 388, , 931
            [order.base.address.address2] => uhehe
            [order.base.address.address3] => 931
            [order.base.address.city] => Jatai
            [order.base.address.state] => GO
            [order.base.address.postal] => 75830-000
            [order.base.address.email] => bbbruno@sandbox.pagseguro.com.br
            [order.base.address.telephone] => 43334443
        )

    [prefix:Aimeos\MShop\Common\Item\Base:private] => order.base.address.
    [values:Aimeos\MShop\Common\Item\Base:private] => Array
        (
            [id] =>
        )

    [values] => Array
        (
            [order.base.address.address4] => Centro
            [order.base.address.areacode] => 64
        )

)



I have:
- Executed `php artisan cache:clear` and `php artisan aimeos:cache`
- Restarted my vagrant machine
- Changed to Firefox (Just in case.... :lol: :lol:)

but the error keeps popping up =((

It clearly HAS the attribute $prefix in the object. Any more hints on what to do now?