I am using Magento EE 2.2.2 version and am facing issue while reorder from admin. I have upgraded from 2.1.7 to 2.2.2 version then only getting issue.
Getting error like " Product "1005961_38_B" not found. This product is no longer available."
Issue only for configurable products, working for simple products.
Please help me to resolve this issue.
I have also faced the same issue. I did debug and found that the catalog_product_super_link (parent_id) table has foreign constraint with catalog_product_entity(row_id)
This issue is occurring if data in the row_id an entity_id are differ
Example
catlog_product_entity
It should be like as below
row_id entity_id
1 1
2 2
3 3
But entries are like below (both column values are not same
row_id entity_id
1 1
3 2
5 3
For temporary fix, i changed the reference key from row_id to entity_id of catalog_product_entity(as the same structure in community edition)
Related
I have two tables which I want to fill their corresponding FOREIGN KEYs simultaneously through a TRIGGER at the time of inserting data into customers table:
CREATE TABLE customers (
customer_id SERIAL PRIMARY KEY,
sld_id integer,
customer_name varchar(35)
);
CREATE TABLE slds (
sld_id SERIAL PRIMARY KEY,
customer_id integer,
sld_code varchar(8) UNIQUE
);
ALTER TABLE customers
ADD CONSTRAINT customers_sld_id_fk
FOREIGN KEY (sld_id)
REFERENCES slds(sld_id);
ALTER TABLE slds
ADD CONSTRAINT slds_customer_id_fk
FOREIGN KEY(customer_id)
REFERENCES customers(customer_id);
I have tried to use an AFTER INSERT trigger function, but NEW.customer_id returned NULL.
Then I used BEFORE INSERT which got me the value of NEW.customer_id. However, because of the constraint and the fact that the insertion didn't take place yet the FOREIGN KEY CONSTRAINT is not fulfilled and I get an error.
I have read here that currval() and lastval() can be used but not recommended.
So I created a proxy table to store the generated values. Then, an AFTER INSERT trigger to fill in those fields back in the related tables.
I thought of using a CREATE TEMP TABLE, but found out that it only lasts for the duration of the calling function and not the connection session. Maybe I misunderstood the error message.
Is this a normal efficient practice? Namely, having a dirty table around just to use for such situations.
Or maybe there is another way to achieve this without using a proxy table?
EDITED:
SAMPLE DATA
customersTABLE:
customer_id slds_id customer_name
1 1 johns
3 2 jenn
4 3 thomas
7 4 jeff
8 5 robin
9 6 chris
10 7 larry
slds TABLE:
slds_id slds_code customer_id
1 SL747561 1
2 SL710031 3
3 SL719995 4
4 SL765369 7
5 SL738011 8
6 SL722232 9
7 SL751591 10
EDIT 2:
Forgot to mention that slds_code is generated within a trigger function:
sld_code varchar(8) := 'SL7'||to_char(floor(random() * 100000 + 1)::int, 'fm00000');
During debugging an issue I found that table "catalog_product_index_tier_price" has a column entity_id which refers to table "sequence_product" column sequence_value. Now for further tracking this sequence_value their is no reference defined for this?
Where actually this sequence_value column values referenced for?
Thanks
Found myself with the same question today.
Debugging further I found that sequence_product.sequence_value has a relation with catalog_product_entity.entity_id and cataloginventory_stock_item.product_id.
That gives me the impression sequence_product is used to maintain a legacy relation for tables that are not in the content staging schema, given that now the primary key for catalog_product_entity is row_id.
Recently I saw a strange scenario with my PostgreSQL DB. The information schema of my database is showing a different sequence name than the one actually allocated for the column of my table.
The issue is:
I have a table tab_1
id name
1 emp1
2 emp2
3 emp3
Previously the id column (integer) of the table was an auto generated field where the sequence number was generated at run time via JPA. (Sequence name: tab_1_seq)
We made a change and updated the table's column id to bigserial and the sequence is maintained in the column level (allocated new sequence: tab_1_temp_seq) not handled by the JPA anymore.
After this change everything was working fine for few months and after that we faced an error - "the sequence "tab_1_temp_seq" is not yet defined in this session"
On analyzing the issue I found out that there is a mismatch between the sequences allocated for the table.
In the table structure, we where shown the sequence as tab_1_temp_seq and in the information_schema the table was allocated with the old sequence - tab_1_seq.
I am not sure what has really triggered this to happen, as we are not managing our database system. If you have faced any issues like this, kindly let me know its root cause.
Queries:
SELECT table_name, column_name, column_default from information_schema.columns where table_name = ‘tab_1’;
result :
table_name column_name column_default
tab_1 id nextval('tab_1_seq::regclass')
Below are the details found in the table structure/properties:
id nextval('tab_1_temp_seq::regclass')
name varChar
Perhaps you are suffering from data corruption, but it is most likely that you are suffering from bad tools to visualize your database objects. Whatever program shows you the “table structure/properties” might be confused.
To find out the truth (which DEFAULT value PostgreSQL uses), run:
SELECT pg_get_expr(adbin, adrelid)
FROM pg_attrdef
WHERE adrelid = 'tab1'::regclass;
This is also what information_schema.columns will show, but I added the naked query for clarity.
This DEFAULT value will be used whenever the INSERT statement either doesn't specify the id column or fills it with the special value DEFAULT.
Perhaps the confusion is also caused by different programs that may set default values in their way. The way I showed above is PostgreSQL's way, but nothing can keep a third-party tool from using its own sequence to filling the id.
I have used Magento 2.2.2 EE. I have Got the Error "No such entity with id = XXXX" while saving the category.
I have Done some points to resolve this issue:
Remove all rows from url_rewrite table for non-existent categories
and products.
Disable all the third party modules.
Re-indexing
But still the issue persist.
I have resolved the issue from my self. The issue is in the url_rewrite table. Product And Categories having deleted Categories URL in this table. Backed up url_rewrite table and search with error id and delete it.
SELECT * FROM url_rewrite WHERE entity_id = XXXX;
SELECT * FROM url_rewrite WHERE target_path LIKE '%/category/XXXX%';
Delete the Records:
DELETE FROM url_rewrite WHERE entity_id = XXXX;
DELETE FROM url_rewrite WHERE target_path LIKE '%/category/XXXX%';
Here's the scenario - Lets say I install a module which changes the column type of a table. And this module changes the type of the date_order field in sale_order table from date to datetime. Now what happens is everytime I restart openerp with updateall modules flag, it drops the original date_order column (with type date) in the table and adds a new column date_order with type datetime.
Now postgres maintains a reference to all of its columns per table in pg_attribute table, which doesnt get cleared even when you drop the columns. Because of this every drop-column-add-column cycle that occurs when you restart openerp increments the column count for the table and in this case its the sale_order table. But the problem is postgres has a column limit of 1600 per table which will be reached if you restart openerp 800 times. And then openerp fails to start.
This is only in case of 1 column. If modules override multiple columns in the table, this limit will be reached sooner.
So the question is, is there a well known way to solve this problem with openerp?
My guess is this is not a very rare case scenario and some people may have already faced this problem. Are there any recommended solutions or conventions or best practices ?
This is how we solved the problem:
Lets say there are two modules sale_order, my_sale_order. Suppose my_sale_order extends the functionality of the sale_order.
And in my_sale_order you want to change the column type of a field in sale_order, lets say, change the type of column order_date from date to datetime. Now, instead of changing the type of order_date to datetime in my_sale_order, what you can do is add a new column called order_datetime whose type is datetime in my_sale_order and change all the references in UI markup(and any other references required for proper functioning) from order_date to order_datetime. You can also keep the order_date and order_datetime in sync in your code.
Btw there are a few solutions being discussed here :
https://www.odoo.com/forum/help-1/question/restarting-openerp-enough-number-of-times-causes-postgres-to-throw-reached-max-column-limit-error-54511