/**
  * Remove the given category and all references to it.
  *
  * \public
  * \static
  */
 static function removeByID($id)
 {
     $id = (int) $id;
     $db = eZDB::instance();
     $db->begin();
     // Delete references to the category from VAT charging rules.
     eZVatRule::removeReferencesToProductCategory($id);
     // Reset product category attribute for all products
     // that have been referencing the category.
     $ini = eZINI::instance('shop.ini');
     if ($ini->hasVariable('VATSettings', 'ProductCategoryAttribute') && ($categoryAttrName = $ini->variable('VATSettings', 'ProductCategoryAttribute'))) {
         $categoryAttrName = $db->escapeString($categoryAttrName);
         $query = "SELECT coa.id FROM ezcontentobject_attribute coa, ezcontentclass_attribute cca, ezcontentobject co " . "WHERE " . " cca.id=coa.contentclassattribute_id " . " AND coa.contentobject_id=co.id " . " AND cca.data_type_string='ezproductcategory' " . " AND cca.identifier='{$categoryAttrName}' " . " AND coa.version=co.current_version " . " AND coa.data_int={$id}";
         $rows = $db->arrayQuery($query);
         foreach ($rows as $row) {
             $query = "UPDATE ezcontentobject_attribute SET data_int=0, sort_key_int=0 WHERE id=" . (int) $row['id'];
             $db->query($query);
         }
     }
     // Remove the category itself.
     eZPersistentObject::removeObject(eZProductCategory::definition(), array("id" => $id));
     $db->commit();
 }