I want to use code such as shown below to create my customer groups programmatically. However I have a requirement to set the Customer IDs to a specific ID numeric range. So if I create 100 customer groups their IDs need to start at 1000 and end with 1100. Is there a way to force the numbering of the ID like I want to do?

require_once 'app/Mage.php';
/* not Mage::run(); */

//Create Customer Group 
     array('customer_group_code' => 'Partners','tax_class_id' => 5))

I have try it too hard you need to by insert direct query

$write = Mage::getSingleton("core/resource")->getConnection("customer_group");
$query =
"INSERT INTO `customer_group`(`customer_group_id`, `customer_group_code`, `tax_class_id`) VALUES (:customer_group_id,:customer_group_code,:tax_class_id)";
$binds = array(
    'customer_group_id'      => 100,
    'customer_group_code'     => "Partners",
    'tax_class_id'   => 5,

$write->query($query, $binds);


You need disabled key

$this->_isPkAutoIncrement = false;


| improve this answer | |
  • That works! I vote you up but my reputation is low. – user2813308004 Sep 18 '14 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.