Page 1 of 2

Undefined property: $prefix

Posted: 05 Sep 2016, 19:32
by brunojti
I made a little of progress trying to add custom fields to address part in checkout.

Now I am getting the following error:

Undefined property: Aimeos\MShop\Order\Item\Base\Address\MyExt::$prefix

(even if I use the Standard manager):

Undefined property: Aimeos\MShop\Order\Item\Base\Address\Standard::$prefix

It starts here:
https://github.com/aimeos/ai-controller ... d.php#L303

And breaks here:
https://github.com/aimeos/aimeos-core/b ... se.php#L66

And here is the var_dump of $address object:

Code: Select all

/var/www/e-commerce/2marchio/vendor/aimeos/aimeos-core/lib/mshoplib/src/MShop/Order/Item/Base/Base.php:282:
object(Aimeos\MShop\Order\Item\Base\Address\Standard)[335]
  private 'values' => 
    array (size=2)
      'order.base.address.siteid' => int 1
      'order.base.address.type' => string 'payment' (length=7)
  private 'prefix' (Aimeos\MShop\Common\Item\Address\Base) => string 'order.base.address.' (length=19)
  private 'modified' (Aimeos\MShop\Common\Item\Base) => boolean true
  private 'values' (Aimeos\MShop\Common\Item\Address\Base) => 
    array (size=12)
      'order.base.address.siteid' => int 1
      'order.base.address.firstname' => string 'xxxxx' (length=5)
      'order.base.address.lastname' => string 'xxxxx' (length=9)
      'order.base.address.vatid' => string 'xxxxx' (length=11)
      'order.base.address.address1' => string 'xxxxxx' (length=18)
      'order.base.address.address2' => string 'uhehe' (length=5)
      'order.base.address.address3' => string '931' (length=3)
      'order.base.address.city' => string 'xxxx' (length=5)
      'order.base.address.state' => string 'xx' (length=2)
      'order.base.address.postal' => string '53444-222' (length=9)
      'order.base.address.email' => string 'xxxxxx' (length=32)
      'order.base.address.telephone' => string '3242312312' (length=10)
  private 'prefix' (Aimeos\MShop\Common\Item\Base) => string 'order.base.address.' (length=19)
  private 'values' (Aimeos\MShop\Common\Item\Base) => 
    array (size=1)
      'order.base.address.siteid' => int 1
Any hints on what I am missing?

Re: Undefined property: $prefix

Posted: 05 Sep 2016, 20:54
by aimeos
I guess, you have overwritten the constructor but didn't call the parent constructor, so no prefix is set:
https://github.com/aimeos/aimeos-core/b ... rd.php#L34

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 00:27
by brunojti
I haven't overwritten the constructor...
I tried to overwrite it (calling the parent constructor but the error is the same).

I have debugged and the code goes all way up to `Common/Item/Base.php` setting the value for $prefix value correctly.
https://github.com/aimeos/aimeos-core/b ... se.php#L37

But the error keeps popping up in the same line as described in the first item of this thread :cry: :cry:

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 11:38
by aimeos
If you post the code of your item class, we can maybe tell you what's wrong :-)

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 12:36
by brunojti
Hi!

Here it is...
Manager: http://pastebin.com/r6vPsQ8P
Item: http://pastebin.com/hZPQRXXT

I was able to bypass the error commenting the line 282 here:
https://github.com/aimeos/aimeos-core/b ... e.php#L282

The id was null anyways... :) But we need to uncomment this line and make it work as it should! :)

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 12:51
by aimeos
Your manager seems to be OK, please show us your new item too.

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 12:54
by brunojti
Just edited my last post ;)

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 13:02
by aimeos
Seems to be OK too. Which PHP version do you use? If PHP 7 is it at least PHP 7.0.4?

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 13:13
by brunojti

Code: Select all

vagrant@vagrant-ubuntu-trusty-64:~$ php -v
PHP 5.5.36-1+donate.sury.org~trusty+1 (cli) (built: May 26 2016 13:10:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Re: Undefined property: $prefix

Posted: 06 Sep 2016, 15:33
by aimeos
Hm, PHP 5.5 is usually not problematic (early versions of PHP 7 are) and I hope you didn't find a PHP bug.
brunojti wrote: And here is the var_dump of $address object:

Code: Select all

/var/www/e-commerce/2marchio/vendor/aimeos/aimeos-core/lib/mshoplib/src/MShop/Order/Item/Base/Base.php:282:
  private 'prefix' (Aimeos\MShop\Common\Item\Base) => string 'order.base.address.' (length=19)
  private 'values' (Aimeos\MShop\Common\Item\Base) => 
The strange thing is that Aimeos\MShop\Common\Item\Base contains the "prefix" property including the right value in your var_dump() output. Can you try to add

Code: Select all

private $prefix
to your own class and see if this works? If not you can try to initialize it with "order.base.address."