Logo
esa saradin @esa
5 mois
Eolia @eolia
5 mois
a répondu au Message de esa saradin - 5 mois
Le ON UPDATE dépend de votre base mais de toute façon c'est le code qui effectue les mises à jour.
Le schéma de base de cette table:

CREATE TABLE `ps_product_shop` (
`id_product` int(11) unsigned NOT NULL,
`id_shop` int(11) unsigned NOT NULL,
`id_category_default` int(11) unsigned DEFAULT NULL,
`id_tax_rules_group` int(11) unsigned NOT NULL,
`on_sale` tinyint(1) unsigned NOT NULL DEFAULT 0,
`online_only` tinyint(1) unsigned NOT NULL DEFAULT 0,
`display_condition` tinyint(1) unsigned NOT NULL DEFAULT 0,
`ecotax` decimal(17,6) NOT NULL DEFAULT 0.000000,
`minimal_quantity` int(11) unsigned NOT NULL DEFAULT 1,
`price` decimal(20,6) NOT NULL DEFAULT 0.000000,
`wholesale_price` decimal(20,6) NOT NULL DEFAULT 0.000000,
`unity` varchar(255) DEFAULT NULL,
`unit_price_ratio` decimal(20,6) NOT NULL DEFAULT 0.000000,
`additional_shipping_cost` decimal(20,2) NOT NULL DEFAULT 0.00,
`customizable` tinyint(2) NOT NULL DEFAULT 0,
`uploadable_files` tinyint(4) NOT NULL DEFAULT 0,
`text_fields` tinyint(4) NOT NULL DEFAULT 0,
`active` tinyint(1) unsigned NOT NULL DEFAULT 0,
`redirect_type` enum('','404','301','302','410','1301','1302','9301','9302') NOT NULL DEFAULT '1302',
`id_product_redirected` int(11) unsigned NOT NULL DEFAULT 0,
`available_for_order` tinyint(1) NOT NULL DEFAULT 1,
`available_date` date NOT NULL DEFAULT '0000-00-00',
`condition` enum('new','used','refurbished') NOT NULL DEFAULT 'new',
`show_price` tinyint(1) NOT NULL DEFAULT 1,
`indexed` tinyint(1) NOT NULL DEFAULT 0,
`visibility` enum('both','catalog','search','none','nowhere') NOT NULL DEFAULT 'both',
`cache_default_attribute` int(11) unsigned DEFAULT NULL,
`advanced_stock_management` tinyint(1) NOT NULL DEFAULT 0,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
`pack_stock_type` int(11) unsigned NOT NULL DEFAULT 3,
`increase_quantity_pack` tinyint(1) unsigned NOT NULL DEFAULT 1,
`never_discounted` tinyint(1) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id_product`,`id_shop`),
KEY `id_category_default` (`id_category_default`),
KEY `date_add` (`date_add`,`active`,`visibility`),
KEY `indexed` (`indexed`,`active`,`id_product`),
KEY `never_discounted` (`never_discounted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
Eolia @eolia
a répondu au Message de Eolia - 5 mois
Le seul cas où la date_add serait mise à jour lors d'un update (Voir ObjectModel) serait si elle est vide, nulle ou égale à 0000-00-00 00:00:00

CODE
if(array_key_exists('date_add', (array)$this)
&& ($this->date_add == null
|| $this->date_add == '0000-00-00 00:00:00')
) {
$this->date_add = date('Y-m-d H:i:s');
if(isset($this->update_fields)
&& is_array($this->update_fields)
&& count($this->update_fields)
) {
$this->update_fields['date_add'] = true;
}
}