Undefined property: $prefix

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!
brunojti
Posts: 27
Joined: 29 Jul 2016, 14:02

Undefined property: $prefix

Post by brunojti » 05 Sep 2016, 19:32

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?

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

Re: Undefined property: $prefix

Post by aimeos » 05 Sep 2016, 20:54

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

brunojti
Posts: 27
Joined: 29 Jul 2016, 14:02

Re: Undefined property: $prefix

Post by brunojti » 06 Sep 2016, 00:27

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:

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

Re: Undefined property: $prefix

Post by aimeos » 06 Sep 2016, 11:38

If you post the code of your item class, we can maybe tell you what's wrong :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

brunojti
Posts: 27
Joined: 29 Jul 2016, 14:02

Re: Undefined property: $prefix

Post by brunojti » 06 Sep 2016, 12:36

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! :)

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

Re: Undefined property: $prefix

Post by aimeos » 06 Sep 2016, 12:51

Your manager seems to be OK, please show us your new item too.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

brunojti
Posts: 27
Joined: 29 Jul 2016, 14:02

Re: Undefined property: $prefix

Post by brunojti » 06 Sep 2016, 12:54

Just edited my last post ;)

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

Re: Undefined property: $prefix

Post by aimeos » 06 Sep 2016, 13:02

Seems to be OK too. Which PHP version do you use? If PHP 7 is it at least PHP 7.0.4?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

brunojti
Posts: 27
Joined: 29 Jul 2016, 14:02

Re: Undefined property: $prefix

Post by brunojti » 06 Sep 2016, 13:13

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

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

Re: Undefined property: $prefix

Post by aimeos » 06 Sep 2016, 15:33

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

Post Reply