Please keep in mind that after “duplicate” follows “save”, which overrides “replacesBlockID” with the “old value”, in most cases “NULL”.
The regarding code “UPDATE … SET replacesBlockID= …” should be placed in the “store” function.
Thanks for reporting this! I’m pretty sure it used to work, but I’ll have a closer look, maybe something has changed..
To add to Manfred’s comment, as I’ve recently been stuck on this, to get this working the “duplicate” and “save” methods need to resemble the following:-
public function duplicate($newbID)
{
parent::duplicate($newbID);
$db = Loader::db();
$db->Execute(‘UPDATE btProductInformation SET replacesBlockID=? WHERE bID=?’,array($this->bID,$newbID));
}
public function save($data)
{
if ( isset($this->replacesBlockID) && $this->replacesBlockID) {
$data[‘replacesBlockID’] = $this->replacesBlockID;
}
3 Comments
Handling multiple block Versions …
Please keep in mind that after “duplicate” follows “save”, which overrides “replacesBlockID” with the “old value”, in most cases “NULL”.
The regarding code “UPDATE … SET replacesBlockID= …” should be placed in the “store” function.
Thanks for reporting this! I’m pretty sure it used to work, but I’ll have a closer look, maybe something has changed..
To add to Manfred’s comment, as I’ve recently been stuck on this, to get this working the “duplicate” and “save” methods need to resemble the following:-
public function duplicate($newbID)
{
parent::duplicate($newbID);
$db = Loader::db();
$db->Execute(‘UPDATE btProductInformation SET replacesBlockID=? WHERE bID=?’,array($this->bID,$newbID));
}
public function save($data)
{
if ( isset($this->replacesBlockID) && $this->replacesBlockID) {
$data[‘replacesBlockID’] = $this->replacesBlockID;
}
parent::save($data);
}