How to extend fe_user on order and confirm email

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
mantik
Posts: 89
Joined: 23 Oct 2017, 05:56

Re: How to extend fe_user on order and confirm email

Post by mantik » 14 Jan 2019, 14:12

The first ist the Exapmle of your documentation. I want extend the customer.
But your example dosen't work.
typo3conf/ext/mantik_aimeos/Resources/Private/Extensions/mantik_aimeos/config/mshop.php:

Code: Select all

<?php
return [
    'customer' => [
        'manager' => [
           'name'=>'Mantikcustomer',
            'standard' =>[
                ...
            ]
        ]
    ]
];

This dosen't change anything. configuration for Customer Standard Manager dosen't work. My Question is why?

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

Re: How to extend fe_user on order and confirm email

Post by aimeos » 15 Jan 2019, 11:24

Your configuration is correct and it works for several others. Does the class exist?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mantik
Posts: 89
Joined: 23 Oct 2017, 05:56

Re: How to extend fe_user on order and confirm email

Post by mantik » 15 Jan 2019, 12:22

Class dosent exist. But i except an error that the class dosent exist.

For example if i do this:

Code: Select all

<?php
return [
    'customer' => [
        'manager' => [
            'lists' =>[
                 'name'=>'Mantikcustomer',
            ]
        ]
    ]
];
I got an error that the class not exists. why not on the standard?
That means for me that the configuration dosen't work.

mantik
Posts: 89
Joined: 23 Oct 2017, 05:56

Re: How to extend fe_user on order and confirm email

Post by mantik » 15 Jan 2019, 12:39

Here i add it for you to show you that the configuration dosen't catch.

typo3conf/ext/mantik_aimeos/Resources/Private/Extensions/mantik_aimeos/config/mshop.php

Code: Select all

<?php
return [
    'customer' => [
        'manager' => [
            'name'=>'Mantikcustomer',
            'standard' =>[
                'insert' => array(
                    'ansi' => '
					INSERT INTO "mshop_customer" (
						"siteid", "label", "code", "company", "vatid", "salutation", "title",
						"firstname", "lastname", "address1", "address2", "address3",
						"postal", "city", "state", "countryid", "langid", "telephone",
						"email", "telefax", "website", "longitude", "latitude", "birthday",
						"status", "vdate", "password", "mtime", "editor", "ctime","saldo"
					) VALUES (
						?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
					)
				'
                ),
                'update' => array(
                    'ansi' => '
					UPDATE "mshop_customer"
					SET "siteid" = ?, "label" = ?, "code" = ?, "company" = ?, "vatid" = ?,
						"salutation" = ?, "title" = ?, "firstname" = ?, "lastname" = ?,
						"address1" = ?, "address2" = ?, "address3" = ?, "postal" = ?,
						"city" = ?, "state" = ?, "countryid" = ?, "langid" = ?,
						"telephone" = ?, "email" = ?, "telefax" = ?, "website" = ?,
						"longitude" = ?, "latitude" = ?, "birthday" = ?, "status" = ?,
						"vdate" = ?, "password" = ?, "mtime" = ?, "editor" = ?, "saldo" = ?
					WHERE "id" = ?
				'
                ),
                'search' => array(
                    'ansi' => '
					SELECT mcus."id" AS "customer.id", mcus."siteid" AS "customer.siteid",
						mcus."label" AS "customer.label", mcus."code" AS "customer.code",
						mcus."company" AS "customer.company", mcus."vatid" AS "customer.vatid",
						mcus."salutation" AS "customer.salutation", mcus."title" AS "customer.title",
						mcus."firstname" AS "customer.firstname", mcus."lastname" AS "customer.lastname",
						mcus."address1" AS "customer.address1", mcus."address2" AS "customer.address2",
						mcus."address3" AS "customer.address3", mcus."postal" AS "customer.postal",
						mcus."city" AS "customer.city", mcus."state" AS "customer.state",
						mcus."countryid" AS "customer.countryid", mcus."langid" AS "customer.languageid",
						mcus."telephone" AS "customer.telephone", mcus."email" AS "customer.email",
						mcus."telefax" AS "customer.telefax", mcus."website" AS "customer.website",
						mcus."longitude" AS "customer.longitude", mcus."latitude" AS "customer.latitude",
						mcus."birthday" AS "customer.birthday", mcus."status" AS "customer.status",
						mcus."vdate" AS "customer.dateverified", mcus."password" AS "customer.password",
						mcus."ctime" AS "customer.ctime", mcus."mtime" AS "customer.mtime",
						mcus."editor" AS "customer.editor", mcus."saldo" AS "customer.saldo"
					FROM "mshop_customer" AS mcus
					:joins
					WHERE :cond
					GROUP BY mcus."id", mcus."siteid", mcus."label", mcus."code",
						mcus."company", mcus."vatid", mcus."salutation", mcus."title",
						mcus."firstname", mcus."lastname", mcus."address1", mcus."address2",
						mcus."address3", mcus."postal", mcus."city", mcus."state",
						mcus."countryid", mcus."langid", mcus."telephone", mcus."email",
						mcus."telefax", mcus."website", mcus."longitude", mcus."latitude",
						mcus."birthday", mcus."status", mcus."vdate", mcus."password",
						mcus."ctime", mcus."mtime", mcus."editor", mcus."saldo"
						/*-columns*/ , :columns /*columns-*/
					/*-orderby*/ ORDER BY :order /*orderby-*/
					LIMIT :size OFFSET :start
				'
                ),
            ]
        ]
    ]
];

typo3conf/ext/mantik_aimeos/Resources/Private/Extensions/mantik_aimeos/lib/custom/src/MShop/Customer/Manager/Mantikcustomer.php

Code: Select all

<?php

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


namespace Aimeos\MShop\Customer\Manager;


/**
 * Default implementation of the customer class.
 *
 * @package MShop
 * @subpackage Customer
 */
class Mantikcustomer extends Standard {

	private $searchConfig = array(
		// no siteid
        'customer.saldo' => array(
            'label' => 'Saldo',
            'code' => 'customer.saldo',
            'internalcode' => 'mcus."saldo"',
            'type' => 'integer',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT
        ),
	);




	/**
	 * Saves a customer item object.
	 *
	 * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object
	 * @param boolean $fetch True if the new ID should be returned in the item
	 * @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID
	 */
	public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
	{
		self::checkClass( '\\Aimeos\\MShop\\Customer\\Item\\Iface', $item );

        if( !$item->isModified() )
		{
			$item = $this->savePropertyItems( $item, 'customer', $fetch );
			$item = $this->saveAddressItems( $item, 'customer', $fetch );
			return $this->saveListItems( $item, 'customer', $fetch );
		}

		$context = $this->getContext();

		$dbm = $context->getDatabaseManager();
		$dbname = $this->getResourceName();
		$conn = $dbm->acquire( $dbname );

		try
		{
			$id = $item->getId();
			$date = date( 'Y-m-d H:i:s' );
			$billingAddress = $item->getPaymentAddress();

			if( $id === null )
			{
				/** mshop/customer/manager/standard/insert/mysql
				 * Inserts a new customer record into the database table
				 *
				 * @see mshop/customer/manager/standard/insert/ansi
				 */

				/** mshop/customer/manager/standard/insert/ansi
				 * Inserts a new customer record into the database table
				 *
				 * Items with no ID yet (i.e. the ID is NULL) will be created in
				 * the database and the newly created ID retrieved afterwards
				 * using the "newid" SQL statement.
				 *
				 * The SQL statement must be a string suitable for being used as
				 * prepared statement. It must include question marks for binding
				 * the values from the customer item to the statement before they are
				 * sent to the database server. The number of question marks must
				 * be the same as the number of columns listed in the INSERT
				 * statement. The order of the columns must correspond to the
				 * order in the saveItems() method, so the correct values are
				 * bound to the columns.
				 *
				 * The SQL statement should conform to the ANSI standard to be
				 * compatible with most relational database systems. This also
				 * includes using double quotes for table and column names.
				 *
				 * @param string SQL statement for inserting records
				 * @since 2014.03
				 * @category Developer
				 * @see mshop/customer/manager/standard/update/ansi
				 * @see mshop/customer/manager/standard/newid/ansi
				 * @see mshop/customer/manager/standard/delete/ansi
				 * @see mshop/customer/manager/standard/search/ansi
				 * @see mshop/customer/manager/standard/count/ansi
				 */
				$path = 'mshop/customer/manager/standard/insert';
			}
			else
			{
				/** mshop/customer/manager/standard/update/mysql
				 * Updates an existing customer record in the database
				 *
				 * @see mshop/customer/manager/standard/update/ansi
				 */

				/** mshop/customer/manager/standard/update/ansi
				 * Updates an existing customer record in the database
				 *
				 * Items which already have an ID (i.e. the ID is not NULL) will
				 * be updated in the database.
				 *
				 * The SQL statement must be a string suitable for being used as
				 * prepared statement. It must include question marks for binding
				 * the values from the customer item to the statement before they are
				 * sent to the database server. The order of the columns must
				 * correspond to the order in the saveItems() method, so the
				 * correct values are bound to the columns.
				 *
				 * The SQL statement should conform to the ANSI standard to be
				 * compatible with most relational database systems. This also
				 * includes using double quotes for table and column names.
				 *
				 * @param string SQL statement for updating records
				 * @since 2014.03
				 * @category Developer
				 * @see mshop/customer/manager/standard/insert/ansi
				 * @see mshop/customer/manager/standard/newid/ansi
				 * @see mshop/customer/manager/standard/delete/ansi
				 * @see mshop/customer/manager/standard/search/ansi
				 * @see mshop/customer/manager/standard/count/ansi
				 */
				$path = 'mshop/customer/manager/standard/update';
			}

			$stmt = $this->getCachedStatement( $conn, $path );

			$stmt->bind( 1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
			$stmt->bind( 2, $item->getLabel() );
			$stmt->bind( 3, $item->getCode() );
			$stmt->bind( 4, $billingAddress->getCompany() );
			$stmt->bind( 5, $billingAddress->getVatID() );
			$stmt->bind( 6, $billingAddress->getSalutation() );
			$stmt->bind( 7, $billingAddress->getTitle() );
			$stmt->bind( 8, $billingAddress->getFirstname() );
			$stmt->bind( 9, $billingAddress->getLastname() );
			$stmt->bind( 10, $billingAddress->getAddress1() );
			$stmt->bind( 11, $billingAddress->getAddress2() );
			$stmt->bind( 12, $billingAddress->getAddress3() );
			$stmt->bind( 13, $billingAddress->getPostal() );
			$stmt->bind( 14, $billingAddress->getCity() );
			$stmt->bind( 15, $billingAddress->getState() );
			$stmt->bind( 16, $billingAddress->getCountryId() );
			$stmt->bind( 17, $billingAddress->getLanguageId() );
			$stmt->bind( 18, $billingAddress->getTelephone() );
			$stmt->bind( 19, $billingAddress->getEmail() );
			$stmt->bind( 20, $billingAddress->getTelefax() );
			$stmt->bind( 21, $billingAddress->getWebsite() );
			$stmt->bind( 22, $billingAddress->getLongitude() );
			$stmt->bind( 23, $billingAddress->getLatitude() );
			$stmt->bind( 24, $item->getBirthday() );
			$stmt->bind( 25, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
			$stmt->bind( 26, $item->getDateVerified() );
			$stmt->bind( 27, $item->getPassword() );
			$stmt->bind( 28, $date ); // Modification time
			$stmt->bind( 29, $context->getEditor() );

			if( $id !== null ) {
				$stmt->bind( 30, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
				$billingAddress->setId( $id ); // enforce ID to be present
				$item->setId( $id );
			} else {
				$stmt->bind( 30, $date ); // Creation time
			}


			/** Mantik */
            $stmt->bind( 31, $item->getSaldo() );
            /** End Mantik */


			$stmt->execute()->finish();

			if( $id === null )
			{
				/** mshop/customer/manager/standard/newid/mysql
				 * Retrieves the ID generated by the database when inserting a new record
				 *
				 * @see mshop/customer/manager/standard/newid/ansi
				 */

				/** mshop/customer/manager/standard/newid/ansi
				 * Retrieves the ID generated by the database when inserting a new record
				 *
				 * As soon as a new record is inserted into the database table,
				 * the database server generates a new and unique identifier for
				 * that record. This ID can be used for retrieving, updating and
				 * deleting that specific record from the table again.
				 *
				 * For MySQL:
				 *  SELECT LAST_INSERT_ID()
				 * For PostgreSQL:
				 *  SELECT currval('seq_mcus_id')
				 * For SQL Server:
				 *  SELECT SCOPE_IDENTITY()
				 * For Oracle:
				 *  SELECT "seq_mcus_id".CURRVAL FROM DUAL
				 *
				 * There's no way to retrive the new ID by a SQL statements that
				 * fits for most database servers as they implement their own
				 * specific way.
				 *
				 * @param string SQL statement for retrieving the last inserted record ID
				 * @since 2014.03
				 * @category Developer
				 * @see mshop/customer/manager/standard/insert/ansi
				 * @see mshop/customer/manager/standard/update/ansi
				 * @see mshop/customer/manager/standard/delete/ansi
				 * @see mshop/customer/manager/standard/search/ansi
				 * @see mshop/customer/manager/standard/count/ansi
				 */
				$path = 'mshop/customer/manager/standard/newid';
				$item->setId( $this->newId( $conn, $path ) );
			}

			$dbm->release( $conn, $dbname );
		}
		catch( \Exception $e )
		{
			$dbm->release( $conn, $dbname );
			throw $e;
		}

		$this->addGroups( $item );

		$item = $this->savePropertyItems( $item, 'customer', $fetch );
		$item = $this->saveAddressItems( $item, 'customer', $fetch );
		return $this->saveListItems( $item, 'customer', $fetch );
	}

    public function getSearchAttributes( $withsub = true ){
        $list = parent::getSearchAttributes($withsub);
        foreach ($this->searchConfig as $key => $fields){
            $list[$key] = new \Aimeos\MW\Criteria\Attribute\Standard($fields);
        }

        return $list;
    }

    protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [], array $addresses = [], array $propItems = []){
        return new \Aimeos\MShop\Customer\Item\Mantikcustomer($values, $listItems, $refItems, $addresses, $propItems);
    }

}
typo3conf/ext/mantik_aimeos/Resources/Private/Extensions/mantik_aimeos/lib/custom/src/MShop/Customer/Item/Mantikcustomer.php

Code: Select all

<?php

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


namespace Aimeos\MShop\Customer\Item;


/**
 * Interface for customer DTO objects used by the shop.
 *
 * @package MShop
 * @subpackage Customer
 */
class Mantikcustomer extends Standard
{

    private $customervalues;
    private $values;

    /**
     * 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 string $salt Password salt (optional)
     * @param \Aimeos\MShop\Common\Item\Helper\Password\Iface|null $helper Password encryption helper object
     * @param \Aimeos\MShop\Customer\Item\Address\Iface[] $addresses List of delivery addresses
     * @param \Aimeos\MShop\Common\Item\Property\Iface[] $propItems List of property items
     */
    public function __construct(

        \Aimeos\MShop\Common\Item\Address\Iface $address,
        array $values = [], array $listItems = [], array $refItems = [], $salt = null,
         \Aimeos\MShop\Common\Item\Helper\Password\Iface $helper = null, array $addresses = [], array $propItems = []
    ){
        parent::__construct( $address, $values, $listItems, $refItems, $addresses, $propItems );
        $this->customervalues = $values;
    }

    /**
     * Returns the saldo of the customer item.
     *
     * @return string Saldo of the customer item
     */
    public function getSaldo()
    {
        if( isset( $this->$customervalues['customer.saldo'] ) ) {
            return (string) $this->customervalues['customer.saldo'];
        }

        return '';
    }

    /**
     * Sets the new saldo of the customer item.
     *
     * @param string $value Saldo of the customer item
     * @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls
     */
    public function setSaldo( $val )
    {
        // don't use checkCode() because maximum length is 255 chars

        if( (string) $val !== $this->getSaldo() )
        {
            $this->values['customer.saldo'] = (string) $val;
            $this->setModified();
        }

        return $this;
    }


    /** END MANTIK*/

	/**
	 * Sets the item values from the given array.
	 *
	 * @param array $list Associative list of item keys and their values
	 * @return array Associative list of keys and their values that are unknown
	 */
	public function fromArray( array $list )
	{
		$unknown = [];
		$list = parent::fromArray( $list );

		foreach( $list as $key => $value )
		{
			switch( $key )
			{
				case 'customer.saldo': $this->setSaldo( $value ); break;
				default: $unknown[$key] = $value;
			}
		}

		return $unknown;
	}


	/**
	 * Returns the item values as array.
	 *
	 * @param boolean True to return private properties, false for public only
	 * @return array Associative list of item properties and their values
	 */
	public function toArray( $private = false )
	{
		$list = parent::toArray( $private );

		if( $private === true )
		{
            $list['customer.saldo'] = $this->getSaldo();
		}

		return $list;
	}
}
If i extend jqadm customer list with the new field:
Image

you know i'm say?
Last edited by mantik on 15 Jan 2019, 12:48, edited 1 time in total.

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

Re: How to extend fe_user on order and confirm email

Post by aimeos » 15 Jan 2019, 12:46

Maybe a dependency problem. Can you add "ai-typo3" to the "depends" section of the manifest.php file in your Aimeos extension (Resources/Private/Extensions)?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mantik
Posts: 89
Joined: 23 Oct 2017, 05:56

Re: How to extend fe_user on order and confirm email

Post by mantik » 15 Jan 2019, 12:51

Done. dosent help... :( Cache cleared, typo3temp deleted, extension reinstalled

mantik
Posts: 89
Joined: 23 Oct 2017, 05:56

Re: How to extend fe_user on order and confirm email

Post by mantik » 17 Jan 2019, 15:12

any news :(?

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

Re: How to extend fe_user on order and confirm email

Post by aimeos » 18 Jan 2019, 09:33

What happens if you configure a non-existing customer manager name?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mantik
Posts: 89
Joined: 23 Oct 2017, 05:56

Re: How to extend fe_user on order and confirm email

Post by mantik » 18 Jan 2019, 09:51

i write this here.

There are sever examples.
mantik wrote:Hello i got an Error here an this step:
...
So i add this just for testing (to be sure that the configuration works an catch.):

Code: Select all

return array(
	'manager' => array(
        'name'=>'Mantikcustomer1',
        'address'=>array(
	        'name'=>'Mantikcustomer2',
	    ),
        'group'=>array(
            'name'=>'Mantikcustomer3',
        ),
        'lists'=>array(
            'name'=>'Mantikcustomer4',
        ),
        'property'=>array(
            'name'=>'Mantikcustomer5',
        ),
        'standard' => array(
            'name'=>'Mantikcustomer6',
        ),
    ),
);
So in the Listview of jQadmin nothing..., if i open i got an error for the configuration lists, group and property (thats ok because there is no class Mantikcustomer1-6. So the error is good. I see now that the configuration go search my classes.

My problem ist why address dosent care? and the bigger problem is why standard dosent care (mantikcustomer1 and mantikcustomer6).

I like to add new fields to jqAdmin so i want the new field in the customer list view but cus my own manager dosent catch i got an error for the setters/getter-methods.

i think to work in the list one of this configurations must work

Code: Select all

	'manager' => array(
        'name'=>'Mantikcustomer1',
        'standard' => array(
            'name'=>'Mantikcustomer6',
        ),
    ),
but it dosent do. (no error that class not exists even when i exept this error).
Dont understand me wrong: no error is good :) but i do it like this to check the configurationhandling.

so result: 3 time it works, 3 time not -> same synthax.... :/
ad the end i can configure customer.group, customer.lists and customer.property. All other things don't catch.

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

Re: How to extend fe_user on order and confirm email

Post by aimeos » 18 Jan 2019, 10:10

Are the names still cached in APCu? You can check if you restart the web server.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply