In my magento admin panel there have Customer ID as 9756.
I need to reset it start with 1.
How can i do this?
You cannot do this (easily) unless you want to remove all customers by truncating the table customer_entity.
Actually you can do this without losing the customers, by changing the id of each one of them starting with 1 and then changing the auto-increment of the customer_entity table using ALTER TABLEcustomer_entityAUTO_INCREMENT = 10; (the value of the autoincrement must be the last id + 1 or it wont work).
I don't recommend this since you can do a lot of damage trying it. The id is used internally so it shouldn't bother you much, unless your OCD sensors are tingling :).
Related
I am creating an Oracle Form. This form has a field by the name FILE_NUM. There is one more field by the name CLIENT_ID in the form. I have to generate unique FILE_NUM. The process is:
If the CLIENT_ID already exists in the table, get the FILE_NUM and assign it to the new record
ELSE, take the maximum of FILE_NUM, add 1 and assign it to the new record.
This should be taken care when multiple users are working on the form. Hence I did the following:
In Key-Commit trigger, I check if there is a lock on the table.
If the table is locked, I make form wait for 3 second and check again.
If the table is not locked, I am locking the table and inserting the records with the above check.
My query is: is this the right way to do? Is there any other way to generate the FILE_NUM (maybe via trigger?). The problem with key-commit trigger is that if the form closes forcefully, the lock is not removed. This will cause more issues, hence I want to remove the lock feature.
Please advice.
This is the correct way, but indeed the lock can stay in some cases.
If the number doesn't have to follow each other you can use a sequence instead.
This will give you a number when needed and it will be unique.
I have looked for an answer here among other places but havent quite been able to find what I need to know.
I have 3 tables, Order_Details, Products_Ordered and Product_Details. The first two are being used in a master detail form to show the order and the items ordered together. The Products_Ordered table has a composite primary key made from two foreign keys, the first being the primary key from the Order_Details table, and the second being the primary key from the Product_Details table. Together they ensure that a type of product can only be added to an order once. If someone wants to order more than one product then the quantity field in the record can be altered to reflect this. All that seems fine so far.
My issue is that when adding products to the order in the master detail form i have used a drop down list of values to select the product to add to the order. the display value for this is the product name and the return value for it is the primary key for the product from the Product_Details table.
I like this because its easier for the user to simply select the product and add a quantity of it to the table. And it works fine for both insert and update operations apart from one situation.
If the user selects the same product in to rows then submits the table the database then tries to add the product to the order twice, throwing a "ORA-00001: unique constraint violated." error. Obviously this is because of the product ID being used in the primary key of the table.
I don't want to allow the user to add two records to the table like that, rather id like to force them to alter the quantity field accordingly. The error message that comes up isn't very user friendly so my question is how can I detect this error and display a more user friendly one instead telling them to alter the quantity field instead?
*If this isn't possible then is there a way that I can hide any already selected products from the dropdown list of values in the following table rows? I haven't looked into this too much because surely it would get complicated when the user tries to add more rows than products available in the dropdown and there are no more products values to show?
I am quite new to this so please be nice. Any help is greatly appreciated :D
Here is a link where all is nicely described:
https://docs.oracle.com/cd/A97630_01/appdev.920/a96624/07_errs.htm
Section
Predefined PL/SQL Exceptions
in combination with:
Defining Your Own PL/SQL Exceptions
and
Defining Your Own Error Messages: Procedure RAISE_APPLICATION_ERROR
Hope it helps...
I have noticed that in my Orders grid in the admin, all the(hundreds) of orders have sequential order ids, all but one. I have 100000103 and then 100000105.
The 100000104 is missing. I have checked this post(magento order id increment jumps) on StackOverflow, but the answer there suggests the following:
If you want to find your 'missing' increment_ids, take a look in sales_flat_quote under the field reserved_order_id. You should see them attached to unconverted quote objects (carts).
But I do not have the missing ID in the specified table for the reserved_order_id column. It is also missing from there, the IDs go 103 and then 105..
I have also checked the abandoned carts reports grid, it is empty.
Should I be concerned that there was some error? The shop owner says he is worried that some order is missing or something..
This is normal, take a look # magento order id increment jumps
When Magento enters the checkout process it 'reserves' an increment_id
and places it on the quote (cart) object and if customer change their mind there will be a missing order id.
Is there a way to globally set the "QtyUsesDecimals" option in magento? My
I'm setting up a Magento site for a client who sells Fabric and other related materials. There is a minimum of .5 yards for any one Fabric product, After that, it can go to any amount, but the minimum is .5. Currently I'm able to type in .25, .125, etc. and add those to the shopping cart.
I only want this to apply to the Fabric products (there are around 2000 different fabric products) but not to the other types she sells on her site, like Rulers, needles, buttons, etc... I don't want people to be able to purchase .5 buttons.
Thanks
I was wondering the same thing, and I just googled this for you and in exactly 5 seconds.. I got the answer (and comprehended it too, mind you):
https://magento.stackexchange.com/questions/6193/magento-product-quantity-uses-decimals
And to apply this to just fabrics.. it should be something like this:
UPDATE `cataloginventory_stock_item`
SET `is_qty_decimal` = 1
WHERE `product_id` IN (
-- INSERT SUBQUERY HERE THAT GETS ALL PRODUCT ID's UNDER THE 'FABRIC' CATEGORY --
-- IT WOULD START WITH 'SELECT `product_id` FROM ..' you do the rest I believe in you --
);
For new/incoming products.. No, there isn't a global config that controls this, and no you can't set it in Default Configuration as it is already a global attribute. Unless, you are willing to invest some time into making an Observer module that sets that attribute for all new products that are created -and- saved (successfully).
There is a database query to solve this issue if the not fabrics products are just a few, or none.
This solution is not update safe and shouldn't be used unless you really understand what you're doing.
ALTER TABLE `cataloginventory_stock_item`
CHANGE COLUMN `is_qty_decimal` `is_qty_decimal` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Is Qty Decimal';
This will change just the default value of this column from DEFAULT '0' to DEFAULT '1'. In Magento 1.7.0.2 the other column fields are untouched, so you can check the query to see if your database version corresponds. Then you should check and rerun this query on each database update.
After executing this query you should modify the value back to '0' to the non fabrics products: you can do all at once via query (check Seth Jeremi Malaki's answer) or through the Admin interface (product->stock) one by one (the secure way).
Otherwise, if the fabric products are a lot less (or none), just keep the database at its state and modify only the fabrics via the admin interface.
In Magento Community v1.5.1.0, how would one go about setting the starting (or next) Customer ID? By default, the first Customer ID is 1. I need to start at Customer ID 300000 after clearing out test data before moving a store into production.
Order, Invoice, Shipment, and Credit Memo ID's can be changed by updating the appropriate values in the eav_entity_store, but (contrary to the information here) there is not an increment entry for Customer ID there.
I scanned the database for a "customer"-related table that would achieve the same thing as eav_entity_store but no dice, and my Google-Fu failed as well.
I thought it was not possible in magento, But it will done by MySql query. Run the below query manually and you will get the user id starts from 300001
ALTER TABLE customer_entity AUTO_INCREMENT = 300001;
There is no increment for customer in eav_entity_store but one can be created, perhaps in a module's install script...
$customerType = Mage::getModel('eav/entity_type')->loadByCode('customer');
Mage::getModel('eav/entity_store')
// customer increments are not per store so store_id is 0
->loadByEntityStore($customerType->getId(), 0)
// increments are varchar, not ints
->setIncrementPrefix('3')
->setIncrementLastId('300000')
->save();