Questions around the TYPO3 integration and plugins as well as Flow and NeosCMS
Forum rules: Always add your TYPO3/Flow, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5249 by mantik
18 Dec 2017, 10:39
Ok i solve it now like this:

Code: Select allnamespace Mantik\MShop\Customer\Item;

class Base extends \Aimeos\MShop\Customer\Item\Base {

   /**
    * Initializes the customer item object
    *
    * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address item object
    * @param array $values List of attributes that belong to the customer item
    * @param \Aimeos\MShop\Common\Lists\Item\Iface[] $listItems List of list items
    * @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items
    * @param \Aimeos\MShop\Common\Item\Address\Iface[] $addresses List of referenced address items
    */
   public function __construct( \Aimeos\MShop\Common\Item\Address\Iface $address, array $values = [],
      array $listItems = [], array $refItems = [], $addresses = [] )
   {
      parent::__construct( 'customer.', $values, $listItems, $refItems );

      foreach( $values as $name => $value )
      {
         switch( $name )
         {
            case 'customer.salutation': $address->setSalutation( $value ); break;
            case 'customer.company': $address->setCompany( $value ); break;
            case 'customer.vatid': $address->setVatId( $value ); break;
            case 'customer.title': $address->setTitle( $value ); break;
            case 'customer.firstname': $address->setFirstname( $value ); break;
            case 'customer.lastname': $address->setLastname( $value ); break;
            case 'customer.address1': $address->setAddress1( $value ); break;
            case 'customer.address2': $address->setAddress2( $value ); break;
            case 'customer.address3': $address->setAddress3( $value ); break;
            case 'customer.postal': $address->setPostal( $value ); break;
            case 'customer.city': $address->setCity( $value ); break;
            case 'customer.state': $address->setState( $value ); break;
            // MANTIK
            case 'customer.languageid':
               switch($value){
                  case 0:
                     $value = 'de';
                     break;
                  case 1:
                     $value = 'fr';
                     break;
                  case 2:
                     $value = 'it';
                     break;
               }
               $address->setLanguageId( $value );
               break;
            // MANTIK
            case 'customer.countryid': $address->setCountryId( $value ); break;
            case 'customer.telephone': $address->setTelephone( $value ); break;
            case 'customer.telefax': $address->setTelefax( $value ); break;
            case 'customer.website': $address->setWebsite( $value ); break;
            case 'customer.longitude': $address->setLongitude( $value ); break;
            case 'customer.latitude': $address->setLatitude( $value ); break;
            case 'customer.email': $address->setEmail( $value ); break;
         }
      }

      // set modified flag to false
      $address->setId( $this->getId() );

      parent::billingaddress($address);
      parent::addresses($addresses);
      parent::data($values);
   }

}


what must i now do to root aimoes to this subclass so i dont have to change every update the core.

i try this:
Code: Select allconfig.tx_extbase {
    persistence {
        classes {
            Aimeos\MShop\Customer\Item\Base {
                subclasses {
                  0 = Mantik\MShop\Customer\Item\Base
                }
            }
        }
    }
}

but dosent work...
#5253 by aimeos
18 Dec 2017, 21:55
You should better solve the problem where it's really rooted and that seems to be where the language is handed over from TYPO3 to Aimeos. There, the languageid already needs to be a two letter ISO string.
#5255 by mantik
19 Dec 2017, 06:15
i think the problem here is cus i've a field "language" in the user table and that works with the numbers of typo3 (like in the switch statement).

but for generally information if i want extend this class how can i do it?
#5262 by aimeos
19 Dec 2017, 12:37
If that's the problem and you can't use the ISO language codes in your fe_users table (or join with another table in the SQL statement that contains the ID:code mapping: https://github.com/aimeos/ai-typo3/blob/master/lib/custom/config/mshop/customer.php#L329), you can extend from the TYPO3 customer manager and overwrite the createItemBase() method: https://github.com/aimeos/ai-typo3/blob/master/lib/custom/src/MShop/Customer/Manager/Typo3.php#L580

You can find the details there: https://aimeos.org/docs/Developers/Library/Extend_managers_items
#5354 by aimeos
05 Jan 2018, 12:55
You mean from the customer manager base class instead of the TYPO3 customer manager? Sure that's possible but then you would have to reimplement the code from the TYPO3 customer manager so we don't suggest that way!