cancel
Showing results for 
Search instead for 
Did you mean: 

Missing eav_entity_store for invoice

Missing eav_entity_store for invoice

Recently I added an english store view to my store in Magento 1.9.2.2.
Italian store view is 1.
English store view id is 2.

When I tried to create an order paying with PayPal i got an error like this:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '200000001' for key 'UNQ_SALES_FLAT_INVOICE_INCREMENT_ID', query was: INSERT INTO `sales_flat_invoice` (`store_id`, `base_grand_total`, `shipping_tax_amount`, `tax_amount`, `base_tax_amount`, `store_to_order_rate`, `base_shipping_tax_amount`, `base_discount_amount`, `base_to_order_rate`, `grand_total`, `shipping_amount`, `subtotal_incl_tax`, `base_subtotal_incl_tax`, `store_to_base_rate`, `base_shipping_amount`, `total_qty`, `base_to_global_rate`, `subtotal`, `base_subtotal`, `discount_amount`, `billing_address_id`, `order_id`, `state`, `shipping_address_id`, `store_currency_code`, `transaction_id`, `order_currency_code`, `base_currency_code`, `global_currency_code`, `increment_id`, `created_at`, `updated_at`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `shipping_incl_tax`, `base_shipping_incl_tax`, `cod_tax_amount`, `base_cod_tax_amount`, `fooman_surcharge_amount`, `base_fooman_surcharge_tax_amount`, `base_fooman_surcharge_amount`, `fooman_surcharge_tax_amount`, `discount_description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '2017-10-02 13:33:30', '2017-10-02 13:33:30', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 

So I looked up in database and looks like there is no invoice entity_store_id for my new english store view.

SELECT * FROM eav_entity_store;
+-----------------+----------------+----------+------------------+-------------------+
| entity_store_id | entity_type_id | store_id | increment_prefix | increment_last_id |
+-----------------+----------------+----------+------------------+-------------------+
|               1 |              5 |        1 | 1                | 100006465         |
|               2 |              6 |        1 | 2                | 200001498         |
|               3 |              8 |        1 | 1                | 100000131         |
|               4 |              7 |        1 | 1                | 100000084         |
|               5 |              5 |        2 | 2                | 200000008         |
+-----------------+----------------+----------+------------------+-------------------+
5 rows in set (0.03 sec)

How is that possible? Should I just add it like this or it could create other problems?

INSERT INTO eav_entity_store (`entity_store_id` ,`entity_type_id` ,`store_id` ,`increment_prefix` ,`increment_last_id`) VALUES ('6', '6', '2', '1', '300000001');

 

 

3 REPLIES 3

Re: Missing eav_entity_store for invoice

@skyw4lker86 your database values suggest that both store_id = 1 and store_id = 2 use the same prefix (2). This is not default behaviour and would suggest someone has changed something in the database directly in the past.

 

Currently both store_id=1 and store_id=2 create entities of type 5 from the same sequence.

 

You want to make sure that all stores create their own separate sequence to avoid an overlap like you have just seen which creates the 

Integrity constraint violation: 1062 Duplicate entry '200000001'

 message.

 

If I was you I probably would change the prefix in this line

|               5 |              5 |        2 | 2                | 200000008         |

from 2 to 3. However if you are planning on adding more stores you will have the same problem again in the future. So you might be better off to change it to a higher number, say change the prefix from 2 to 20.

Re: Missing eav_entity_store for invoice


Currently both store_id=1 and store_id=2 create entities of type 5 from the same sequence.

Hello @Fooman, thanks for you reply!

With "same sequence" you mean that both stores have increment prefix = 2?

Because as you can see they have different "increment_last_id"

 

So you would suggest just to update the value as here, without adding any values for invoices (entity_type_id=6)? 

|               5 |              5 |        2 | 20                | 200000008         |

When I do not add a new line for invoice, magento seems unable to create invoices, and keeps showing up errors for store 2 also when trying to complete the order "There was an error processing your order. Please contact us or try again later."


Thanks

Re: Missing eav_entity_store for invoice

What about this, would it be ok?

 

| entity_store_id | entity_type_id | store_id | increment_prefix | increment_last_id |
+-----------------+----------------+----------+------------------+-------------------+
|               1 |              5 |        1 | 1                | 100006466         |
|               2 |              6 |        1 | 2                | 200001499         |
|               3 |              8 |        1 | 1                | 100000131         |
|               4 |              7 |        1 | 1                | 100000084         |
|               5 |              5 |        2 | 20               | 2000000010        |
|               6 |              6 |        2 | 30               | 300000001         |
+-----------------+----------------+----------+------------------+-------------------+
6 rows in set (0.12 sec)