/** * Restore categories when restoring a product * * @param int $intId * @param string $strTable * @param array $arrData * @param int $intVersion */ public function restoreVersion($intId, $strTable, $arrData, $intVersion) { if ($strTable != Product::getTable()) { return; } $arrData = SubtableVersion::find(ProductCategory::getTable(), $intId, $intVersion); if (null !== $arrData) { \Database::getInstance()->query("DELETE FROM " . ProductCategory::getTable() . " WHERE pid={$intId}"); foreach ($arrData as $arrRow) { \Database::getInstance()->prepare("INSERT INTO " . ProductCategory::getTable() . " %s")->set($arrRow)->execute(); } } }
/** * Restore pricing information when restoring a product * @param int * @param string * @param array * @param int */ public function restoreVersion($intId, $strTable, $arrData, $intVersion) { if ($strTable != Product::getTable()) { return; } $arrData = SubtableVersion::find(ProductPrice::getTable(), $intId, $intVersion); if (null !== $arrData) { \Database::getInstance()->query("DELETE FROM tl_iso_product_pricetier WHERE pid IN (SELECT id FROM " . ProductPrice::getTable() . " WHERE pid={$intId})"); \Database::getInstance()->query("DELETE FROM " . ProductPrice::getTable() . " WHERE pid={$intId}"); foreach ($arrData['prices'] as $arrRow) { \Database::getInstance()->prepare("INSERT INTO " . ProductPrice::getTable() . " %s")->set($arrRow)->execute(); } foreach ($arrData['tiers'] as $arrRow) { \Database::getInstance()->prepare("INSERT INTO tl_iso_product_pricetier %s")->set($arrRow)->execute(); } } }