mon plugin n'a absolument aucun effet alors qu'il marche si je met a jour n'importe quoi d'autre, et si je récupère les requetes générées et les colle dans phpmyadmin tout marche
class plgHikashopSynchro extends JPlugin
{
function __construct(&$subject, $config) {
parent::__construct($subject, $config);
}
function onAfterProductUpdate(&$product) {
$this->_productSynchro($product);
}
function onAfterProductCreate(&$product) {
$this->_productSynchro($product);
}
function _productSynchro(&$product) {
$s = '';
$pid = $product->product_id;
$psize = explode(',',$product->product_size_values);
//$pquantity = $product->product_quantity;
$cat_parentid = 400;
$catid = $cat_parentid;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$conditions = array(
$db->quoteName('category_parent_id') . ' = ' .$cat_parentid,
$db->quoteName('product_id') . ' = ' . $pid
);
$query->delete($db->quoteName('#__hikashop_product_category'));
$query->where($conditions);
$db->setQuery($query);
$db->execute();
$s .= $query . '<br />';
$query->clear;
$columns = array('product_id', 'category_id', 'category_parent_id');
foreach($psize as $ps){
$catid += $ps;
$values = array($pid, $catid, $cat_parentid);
$query = $db->getQuery(true);
$query
->insert($db->quoteName('#__hikashop_product_category'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
$db->setQuery($query);
$query = str_replace('INSERT', 'INSERT IGNORE', $query);
$db->setQuery($query);
try {
$db->execute();
} catch (Exception $e) {
echo $e->getMessage() . $query;
}
$s .= $query . '<br />';
$query->clear;
$catid = $cat_parentid;
}
echo $product->product_size_values;
echo '<br />';
echo $s;
}
}
quest ce qui bloque ?
mon echo donne bien
46,47,48
DELETE FROM `#__hikashop_product_category` WHERE `category_parent_id` = 400 AND `product_id` = 60
INSERT IGNORE INTO `#__hikashop_product_category` (`product_id`,`category_id`,`category_parent_id`) VALUES (60,446,400)
INSERT IGNORE INTO `#__hikashop_product_category` (`product_id`,`category_id`,`category_parent_id`) VALUES (60,447,400)
INSERT IGNORE INTO `#__hikashop_product_category` (`product_id`,`category_id`,`category_parent_id`) VALUES (60,448,400)
si je recupere les requetes dans un echo et que je les execute directement dans la base tout marche
merci