Magento 2 different prices on page product and search results - magento

For some reason I have for some,different prices on page product and search results.
The correct one is on the product page.
For example product page is 1.60 and search result page 1.20.
What I have done:
I have Magento 2.4.4
Change the product price in admin,I check the catalog_product_entity_decimal table to see the changes and it is update, then I see that I have to reindex the catalog_product_price index.
Once that is done the price is updated in the catalog_product_index_price table, but when I check the _replica one (catalog_product_index_price_replica) it is not updated.
This only happends to some products.Not sure what is happening
Because this is a search result page, I am using Amasty Elastic Search

I figured it out,it seems that in my case , when I updated a specific third party module, there was some sort of update on the table catalog_product_index_price_tmp.
I deleted the table and created it manually, bad mistake, this table is used for updating the catalog product index (not sure if others), it stores the information on that table and then copies its values to the _replica one, this table is always emptied when reindexing the price.
Solution was to delele the table
DROP TABLE `catalog_product_index_price_tmp`;
And then run the setup:upgrade , this table is created by magentos db_schema.xml in this file vendor/magento/module-catalog/etc/db_schema.xml
Hope this helps others

Related

How to change in the Magento DB the prices of the product

I've troubles to figure out how to change the prices of a product in the magento DB.
I tryed to change the prices in the catalog_product_index_price table but the price doesn't change.
There is a website here that explains it in more detail, but the short answer is that you need to change the price in the catalog_product_entity_decimal table and then reindex Product Prices in the backend (and potentially Product Flat Data as well)
Magento uses variety of indexing and caching methods that make simply changing the value directly in the database not a good idea.
If you look, you can see the prices are also defined in the Price Index tables:
catalog_product_index_price_idx
And also the flat tables (if you use them):
catalog_product_flat_1 (number 1 depends on store)
If you're trying to mass update prices, I recommend either using a tool such as Magmi or the built in Magento import methods to update prices. Directly modifying the database is generally not a good idea with Magento, given it's complex database structure.

Magento reports empty rows

When I'm generating a report of the most viewed products there are a lot of empty rows. So from some day's I cant get any data of the most viewed products. There is reasonable traffic on the site and I know for sure that every day products are viewed.
It is a Magento 1.6 webshops. Other reports are working correctly.
Does anyone know what the problem could be?
The issue is most likely coming from the DB which is used to generate this report.
Browse the table generating reports for Most Viewed Product and if you find “store_id” empty, edit and select the correct store_id for your store.
I run the following query to update all order items:
UPDATE table_name SET store_id=1 WHERE store_id =null;
This is assuming you only have 1 store and its store id = 1.
Also, take backup before running.

How does Magento store deleted products in database

I'm running a script that exports magento products in an xml. I do the query using SQL connections and selecting all attributes. It there a way or how can I find information of deleted products in a magento database?
only way to find out is to have a list of all existing products or products that have existed and compare them against current dataset. Other way would be never delete a product but mark them as out of stock or inactive

Magento coupon entities in database

I'm trying to develop a Magento plugin which involves using coupons. Apparently after looking around I found a source that mentions use of a 'salesrule' table for coupons. However when I looked at my database i couldn't find it. However I did find 3 tables that had mention 'coupon' called 'coupon_aggregated', 'coupon_aggregated_order', and 'coupon_aggregated_updated'.
I just wanted to know what is the difference between the 3 tables so I can start using them? I am on the latest version of Magento.
The table you're looking for is indeed named
salesrule
There's also a table named salesrule_coupon, which contains specific coupon codes linked back to the main salesrule definition.
If your database is missing this table, something bad has happened to your system. Go to
Promotions -> Shopping Cart Price Rules
and create a new coupon code with a distinct title. Then dump your database content and search for the text of your distinct title. That will let you know which table your system is storing salesrules in.
The tables you mentioned above are aggregate data tables used for reporting only.

Magento: Revert price data from index. False price data saved, but not indexed

i hope i am able to describe the problem correctly here, as it is quite complex. I guess you guys are my last chance.
We have ca. 120 config products based on 600 simple products. Some days ago, we accidently overwrote all the prices of the simple products with false prices. We did not notice as in the frontend every price is still ok, they are not indexed.
So we now have the correct prices in the frontend, but the wrong prices for the simple products in the backend.
Is there any method the get the prices from the indexed frontend and write them back in the backend?
Until i reindex all proces should be ok in the frontend.
Does anyone have any idea what i could do to get the prices right again?
If you browse the database, there should be a catalog_product_flat_1 table - this is basically your product index. You should have columns for all the product attributes (including SKU and Price) so you could export this table, then do a product export from Magento, then update all the prices/SKUs accordingly and re-import. Or duplicate the flat_1 table, then write a PHP script to loop through it, updating all the prices, then re-index your data (after checking it's worked of course!)

Resources