Can I Make A Product Collection Use Flat Tables in Magento - magento

In my Magento store I currently have Flat Catalog Product turned Off because it breaks some custom code I have on my site.
However, I am have a single instance where it would greatly help me to have the collection use the flat table as opposed to the EAV tables.
Is there a way I can tell the product collection to use the flat tables as opposed to the EAV tables in my code?

This is a great opportunity to fix your custom code :) In the default system, flat catalog is either turned on or off, not with any level of granularity. Depending on the nature of the hack that breaks the flat catalog, it may be possible to avoid that issue and just it turned on globally.
Perhaps more detail into the issue that caused you to leave it turned off?

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.

Category coming at inappropriate place

I worked on this and it is live now. Please have a look at it. The problem is that the category named "Carbide rod" is not assigned to that "PCD inserts" category. But still showing. I don't know whats the problem in it. Please help me on it.
You probably have enabled flat tables to be used on front, which is generally a good idea. The thing to remember, though, is to perform a Category Flat Data re-index in Admin Panel. Go to System > Index Management and do a reindex of Category Flat Data.
Next you should Flush Cache Storage at System > Cache Management.
If that won't help, then check how your category tree looks on a Store View level. Magento allows to have different category trees for each store view.
Carbide rods category is not displayed under PCD inserts, whats your question exactly I'm not getting it.

Import url rewrites to magento

I often get to the point in building a new Magento site where 301 rewrites need creating for all the items on the old site. Is there a way of importing them directly?
Programmatically via a urlCreate() type Magento function would be fine as then I could just cycle through a csv.
Generally it's a good idea to stick with Magento's ORM for interacting with entity data, as there may be both business logic and storage logic which is baked into the entity ORM stack (this is notoriously true for EAV entities). But, depending on the number of records to be entered, a direct-to-db approach should be fine, especially if it's a one-off import. This is because URL rewrites are flat entities stored in the core_url_rewrite table (link), and the table itself has the necessary storage logic as part of its structure (mainly, unique request_path + store_id and an FK for core_store table). In other words, manipulating this data outside of the ORM tier is okay because the logic is part of the table definition itself.
Beyond this information, it's possible to load up a core/url_rewrite collection, create core/url_rewrite instances from the CSV and add them, and then call save() on the collection, but note that each item is saved individually. It might do to refer to the convert adapters for catalog entities and for customers, which is how dataflow works.

How do magento convert EAV data to Flat data?

Can anyone please explain me this?
Which classes and methods are related to updating the EAV attribute values in the flat catalog tables?
What factors allow for attributes to be added to flat catalog tables?
Yes I did the homework, searched on net and checked the Magento source code but unable to come with any satisfactory answer.
Thanks!

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.

Resources