its not about the customer manager i extend the oder base manager. and i do all that what you write.
here is my whole code so you can check it
typo3conf/ext/my_shop/Resources/Private/Extensions/my_shop/lib/custom/config/mshop/order.php
Code: Select all
<?php
return array(
'manager' => array(
'base' => array(
'name'=>'Myorder',
'standard' => array(
'insert' => array(
'ansi' => '
INSERT INTO "mshop_order_base" (
"customerid", "sitecode", "langid", "currencyid",
"price", "costs", "rebate", "tax", "taxflag", "comment",
"status", "mtime", "editor", "myid", "siteid", "ctime"
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
'
),
'update' => array(
'ansi' => '
UPDATE "mshop_order_base"
SET "customerid" = ?, "sitecode" = ?, "langid" = ?, "currencyid" = ?,
"price" = ?, "costs" = ?, "rebate" = ?, "tax" = ?, "taxflag" = ?,
"comment" = ?, "status" = ?, "mtime" = ?, "editor" = ?,"myid" = ?
WHERE "siteid" = ? AND "id" = ?
'
),
'search' => array(
'ansi' => '
SELECT mordba."id" AS "order.base.id", mordba."siteid" AS "order.base.siteid",
mordba."sitecode" AS "order.base.sitecode", mordba."customerid" AS "order.base.customerid",
mordba."langid" AS "order.base.languageid", mordba."currencyid" AS "order.base.currencyid",
mordba."price" AS "order.base.price", mordba."costs" AS "order.base.costs",
mordba."rebate" AS "order.base.rebate", mordba."tax" AS "order.base.taxvalue",
mordba."taxflag" AS "order.base.taxflag", mordba."comment" AS "order.base.comment",
mordba."status" AS "order.base.status", mordba."mtime" AS "order.base.mtime",
mordba."editor" AS "order.base.editor", mordba."ctime" AS "order.base.ctime",
mordba."myid" AS "order.base.myid"
FROM "mshop_order_base" AS mordba
:joins
WHERE :cond
GROUP BY mordba."id", mordba."siteid", mordba."sitecode", mordba."customerid",
mordba."langid", mordba."currencyid", mordba."price", mordba."costs",
mordba."rebate", mordba."tax", mordba."taxflag", mordba."comment", mordba."status",
mordba."mtime", mordba."editor", mordba."ctime" /*-columns*/ , :columns /*columns-*/
/*-orderby*/ ORDER BY :order /*orderby-*/
LIMIT :size OFFSET :start
'
),
'newid' => array(
'db2' => 'SELECT IDENTITY_VAL_LOCAL()',
'mysql' => 'SELECT LAST_INSERT_ID()',
'oracle' => 'SELECT mshop_order_base_seq.CURRVAL FROM DUAL',
'pgsql' => 'SELECT lastval()',
'sqlite' => 'SELECT last_insert_rowid()',
'sqlsrv' => 'SELECT SCOPE_IDENTITY()',
'sqlanywhere' => 'SELECT @@IDENTITY',
),
)
)
)
);
?>
typo3conf/ext/my_shop/Resources/Private/Extensions/my_shop/lib/custom/src/MShop/Order/Item/
Base/Myorder.php
Code: Select all
<?php
namespace Aimeos\MShop\Order\Item\Base;
class Myorder extends Standard{
private $price;
private $locale;
private $values;
private $modified = false;
/**
* Initializes the shopping cart.
*
* @param \Aimeos\MShop\Price\Item\Iface $price Default price of the basket (usually 0.00)
* @param \Aimeos\MShop\Locale\Item\Iface $locale Locale item containing the site, language and currency
* @param array $values Associative list of key/value pairs containing, e.g. the order or user ID
* @param array $products List of ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface
* @param array $addresses List of order addresses implementing \Aimeos\MShop\Order\Item\Base\Address\Iface
* @param array $services List of order services implementing \Aimeos\MShop\Order\Item\Base\Service\Iface
* @param array $coupons Associative list of coupon codes as keys and ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface as values
*/
public function __construct(\Aimeos\MShop\Price\Item\Iface $price, \Aimeos\MShop\Locale\Item\Iface $locale,
array $values = [], array $products = [], array $addresses = [],
array $services = [], array $coupons = [] )
{
parent::__construct( $price, $locale, $values, $products, $addresses, $services, $coupons );
$this->price = $price;
$this->locale = $locale;
$this->values = $values;
}
public function getMyid(){
if( isset( $this->values['order.base.myid'] ) ) {
return (string) $this->values['order.base.myid'];
}
return 0;
}
public function setMyid( $myid ){
if( (string) $myid !== $this->getMyid() ){
$this->values['order.base.myid'] = (string) $myid;
$this->modified = true;
}
return $this;
}
public function fromArray( array $list ){
$unknown = [];
$list = parent::fromArray( $list );
foreach( $list as $key => $value )
{
switch( $key ){
case 'order.base.myid': $this->setMyid( $value ); break;
default: $unknown[$key] = $value;
}
}
return $unknown;
}
public function toArray( $private = false ){
$list = parent::toArray( $private );
if( $private === true ) {
$list['order.base.myid'] = $this->getMyid();
}
return $list;
}
}
typo3conf/ext/my_shop/Resources/Private/Extensions/my_shop/lib/custom/src/MShop/Order/Manager/
Base/Myorder.php
Code: Select all
<?php
namespace Aimeos\MShop\Order\Manager\Base;
class Myorder extends Standard {
private $searchConfig = array(
'order.base.myid' => array(
'code' => 'order.base.myid',
'internalcode' => 'mordba."myid"',
'label' => 'My ID',
'type' => 'string',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR
)
);
/**
* Adds or updates an order base item in the storage.
*
* @param \Aimeos\MShop\Common\Item\Iface $item Order base object (sub-items are not saved)
* @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 )
{
$iface = '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface';
if( !( $item instanceof $iface ) ) {
throw new \Aimeos\MShop\Order\Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
}
if( !$item->isModified() ) {
return $item;
}
$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' );
if( $id === null ){
$path = 'mshop/order/manager/base/standard/insert';
} else {
$path = 'mshop/order/manager/base/standard/update';
}
$priceItem = $item->getPrice();
$localeItem = $context->getLocale();
$stmt = $this->getCachedStatement( $conn, $path );
$stmt->bind( 1, $item->getCustomerId() );
$stmt->bind( 2, $localeItem->getSite()->getCode() );
$stmt->bind( 3, $item->getLocale()->getLanguageId() );
$stmt->bind( 4, $priceItem->getCurrencyId() );
$stmt->bind( 5, $priceItem->getValue() );
$stmt->bind( 6, $priceItem->getCosts() );
$stmt->bind( 7, $priceItem->getRebate() );
$stmt->bind( 8, $priceItem->getTaxValue() );
$stmt->bind( 9, $priceItem->getTaxFlag(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$stmt->bind( 10, $item->getComment() );
$stmt->bind( 11, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$stmt->bind( 12, $date ); // mtime
$stmt->bind( 13, $context->getEditor() );
$stmt->bind( 14, $item->getMyid() );
$stmt->bind( 15, $localeItem->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
if( $id !== null ) {
$stmt->bind( 16, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
$item->setId( $id );
} else {
$stmt->bind( 16, $date ); // ctime
}
$stmt->execute()->finish();
if( $id === null && $fetch === true ){
$path = 'mshop/order/manager/base/standard/newid';
$item->setId( $this->newId( $conn, $path ) );
}
$dbm->release( $conn, $dbname );
}
catch( \Exception $e ){
$dbm->release( $conn, $dbname );
throw $e;
}
return $item;
}
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( \Aimeos\MShop\Price\Item\Iface $price, \Aimeos\MShop\Locale\Item\Iface $locale,
array $values = [], array $products = [], array $addresses = [],
array $services = [], array $coupons = [] ){
return new \Aimeos\MShop\Order\Item\Base\Myorder($price, $locale, $values, $products, $addresses, $services, $coupons);
}
}
?>
So what works:
- i can see the field in the Backendmodule by order and i can read the values if i post it direct in the database. so getter works
- i can filter
- i can sort
whats wrong:
- i can open an order and see the values of order.base.myid BUT if i change something after reload the old values stays.
in frontend: as soon i put something in the basket (why basket i extend the order?) i got a php expetion: Call to a member function getSite() on null
in