Skip to content

Basket Manager does not save extended attributes on update #331

@nvindice

Description

@nvindice

Hi Aimeos team,

one more issue with the Manager extension: the basket manager does save extended attributes (via the $columns array) when saving the basket for the first time. However, the custom values are ignored when updating an existing basket.

$columns = $this->getSaveColumns();
/** mshop/basket/manager/insert/mysql
* Inserts a new basket record into the database table or updates an existing one
*
* 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 basket 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 save() 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 or updating records
* @since 2022.10
* @see mshop/basket/manager/newid/ansi
* @see mshop/basket/manager/delete/ansi
* @see mshop/basket/manager/search/ansi
* @see mshop/basket/manager/count/ansi
*/
$path = 'mshop/basket/manager/insert';
$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ) );
$stmt = $this->getCachedStatement( $conn, $path, $sql );
$serialized = base64_encode( serialize( clone $item->getItem() ) );
$idx = 1;
foreach( $columns as $entry ) {
$stmt->bind( $idx++, $item->get( $entry->getCode() ), \Aimeos\Base\Criteria\SQL::type( $entry->getType() ) );
}
// insert
$stmt->bind( $idx++, $item->getCustomerId() );
$stmt->bind( $idx++, $serialized );
$stmt->bind( $idx++, $item->getName() );
$stmt->bind( $idx++, $date ); //mtime
$stmt->bind( $idx++, $context->editor() );
$stmt->bind( $idx++, $this->siteId( $item->getSiteId(), \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE ) );
$stmt->bind( $idx++, $date ); //ctime
$stmt->bind( $idx++, $item->getId() );
// update
$stmt->bind( $idx++, $item->getCustomerId() );
$stmt->bind( $idx++, $serialized );
$stmt->bind( $idx++, $item->getName() );
$stmt->bind( $idx++, $date ); //mtime
$stmt->bind( $idx++, $context->editor() );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions