Hello. The site adminpanel implements the functionality of mass category assignment to the list of items, which replaces the current category value for the selected list with a new one. How to make the function add new values to the old, and not replace them? For example, there are 5 elements that are in category A, how to make it so that when adding categories B and C, we get all three ABCs. Below is the code that performs the process of mass association of categories to the selected elements. (I apologize for the amateurish formulation). thank
public function massxref_cats(){ $this->massxref('massxref'); } public function massxref_cats_exe(){ $virtuemart_cat_ids = vRequest::getInt('cid', array() ); $session = JFactory::getSession(); $cids = json_decode($session->get('vm_product_ids', array(), 'vm'),true); $productModel = VmModel::getModel('product'); foreach($cids as $cid){ $data = array('virtuemart_product_id' => $cid, 'virtuemart_category_id' => $virtuemart_cat_ids); $data = $productModel->updateXrefAndChildTables ($data, 'product_categories',TRUE); } $this->massxref('massxref_cats'); } public function massxref($layoutName){ vRequest::vmCheckToken(); $cids = vRequest::getInt('virtuemart_product_id'); if(empty($cids)){ $session = JFactory::getSession(); $cids = json_decode($session->get('vm_product_ids', '', 'vm'),true); } else { $session = JFactory::getSession(); $session->set('vm_product_ids', json_encode($cids),'vm'); } if(!empty($cids)){ $q = 'SELECT `product_name` FROM `#__virtuemart_products_' . VmConfig::$vmlang . '` '; $q .= ' WHERE `virtuemart_product_id` IN (' . implode(',', $cids) . ')'; $db = JFactory::getDbo(); $db->setQuery($q); $productNames = $db->loadColumn(); vmInfo('COM_VIRTUEMART_PRODUCT_XREF_NAMES',implode(', ',$productNames)); } $this->addViewPath(VMPATH_ADMIN . DS . 'views'); $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView($this->_cname, $viewType); $view->setLayout($layoutName); $view->display(); }