Ability to connect Magento to existing database? - magento

I have an existing database that contains 4 tables: categories, sub-categories, products, prices. I am looking to create an ecom site using Magento leveraging the existing tables. I would rather not import the tables since products will be continually modified. I am new to Magento. What is the best way to handle this? Would I want to query my existing tables and hook into Magento bypassing their product tables? Is there a way to do this? Thanks!

I think you're choosing the wrong e-commerce system if want to use your existing database in place of the one in Magento. Magento doesn't work like this. You can't have the Magento interface and not the guts of it. They are inextricably bound (some would say, tightly coupled).
I would hire a Magento programmer and have him or her create a module for you to import your products into the Magento catalog. This module should be able to handle updates to your existing database. This can be done easily as the Magento catalog model uses the entity-attribute-value (EAV) database model pattern. Then you can continue using your database.

Related

Magmi Datapump API - Item not showing in store

When I add a product with Magmi Datapump API, the product shows up in the Manage Products page but the product is not visible in the store.
I open the product in the Manage Products page for editing and just hit save and the product shows up in the store. Is Magento doing some stuff in the backend when I save the product manually?
Also, when I save the product manually I get this message:
The export profile-product relations has been updated.
This meesage was not there before.
You haven't mentioned the Magento version you're using, but I'll assume it's something in the vicinity of 1.8/1.9 CE or above.
What is Magmi?
Magmi is a third party package/utility that lets you import data directly into Magento. It reads the Magento configuration (model's table names, structure, types etc) and uses it to write directly to a MySQL database.
The purpose of this is that it bypasses the Magento ORM layer - this provides benefits in some situations, primarily speed. The drawback is that unless you're doing it because you know exactly why you're doing it and what the drawbacks of it are already, you miss things that happen with Magento's ORM - particularly event observers and pre/post write callbacks.
When you save a product
By default in Magento when you save a product in the admin interface it will write directly to the database through the ORM via the $model->save() operation.
This process by association (via _afterSave or event observers) does one of two things (if you have flat product tables enabled, which I assume you do):
Reindex the product flat tables synchronously/in the same request process
Schedule a reindex of the product flat tables to be performed via the cron
Depending on your Magento version the default setting of the product flat index will be important here. 1.9 introduces scheduling them by default I believe, whereas older versions would run them synchronously by default.
Enterprise edition: If you're running an enterprise version, MySQL table triggers should actually detect these product record changes automatically anyway, and schedule a reindex via the changelog tables (*_cl). For this question I'll assume you're using community edition.
What you're missing
Going back to Magmi - it writes directly to the database tables and so skips the ORM layer, which includes the commands for reindexing.
When you press Save in Magento admin on a product (and you say this makes your changes work) indexing is performed automatically for this product - synchronously. This behaviour indicates that your product flat index is set to be run "on save" rather than "on schedule". This is why you see the product on the frontend after saving it again in admin, purely because the Magento ORM triggers the reindex for that product which inserts it into the product flat table (e.g. catalog_product_flat_1). If you were aware, these tables are the tables that the frontend of Magento reads from when you have flat tables enabled - this is to avoid the complexity of the EAV model structure and the many joins (and configuration lookup/processing) that are required to read from the product (and other) models. Flat tables (indexed) have everything they need in long, but single rows.
What you need to do
So - all that being said - we can assume your product flat index is set to run on save.
What I would suggest primarily is that you change it to run "on schedule". You can do this from the Magento admin panel via System -> Index Management.
From here you need to enable the Magento system cron.
This will work if your CE (community edition) version has MySQL table triggers that update the changelog tables. You can check for this.
If not, you'll need to trigger a reindex manually. Depending on how you are calling Magmi, you could do this one of two ways:
Magmi via command line
Trigger a command line initiated reindex of product related data after you've run the Magmi import command:
php indexer.php --reindex catalog_product_price,catalog_url,catalog_product_flat
Magmi via PHP
If you're running Magmi from a thirdparty integration script which is not triggered from command line, or you don't want to add a CLI command like the one above afterwards (again, you don't mention these details), you can tack on a reindexing PHP script to the end of your Magmi datapump call:
foreach (...) {
$datapump->ingest($data);
}
$datapump->endImportSession();
// reindex now!
foreach (['catalog_product_price', 'catalog_url', 'catalog_product_flat'] as $indexCode) {
$process = Mage::getModel('index/indexer')->getProcessByCode($indexCode);
$process->reindexAll();
}
TL;DR
Ensure you reindex your product data after importing with Magmi, since it skips the Magento ORM which would normally take care of this for you.

Transferring / Migrating an entire Catalog in Magento

I've been trying to transfer the entire catalog from one Magento server to another and I've been experiencing some significant problems.
I can get most of the catalog data across, but I always end up missing something like product swatches, product categories or a product's custom options. To get these across I then end up building my own scripts that queries Magento, writes the data to a CSV file of my own design, and then write another script that will add this data to the other server.
Ive been asking the other developers in house, and apparently this is how they do every migration. They spend ages building lots of custom scripts just to transfer the catalog across, and apparently the different Magento sites are so different they have to build entirely new scripts when they transfer the next site.
Is this a common experience for everybody?
I feel like there must be a better way. Does anybody know of a better way to transfer the entire catalog (not just the products, but everything) to another server? Can we not just copy across the entire SQL Database?
You can export the products using Magento export wizard by going into System -> import/export ->export
Then from export settings select Entity type Products and Export File Format as CSV
After getting the CSV file you can import the whole catalog using the Magento same wizard or You can use data flow.
The other option around to import bigger catalogs in Magento is to Use Magmi.
http://wiki.magmi.org/index.php?title=Magmi_Wiki
I hope this will help
There are many ways you can migrate your magento store from one server to another.
If you want to transfer complete magento site, then you should try with database import/export. Its easy and fast process. You can follow Site Ground tutorial for this
If you want to transfer only data such as product, catalog, customers, orders etc, then you can try magmi importer its easy and fast for importing data. Also you can try magento data flow profiles as well.

adding data directly to a magento database

I am adding regions of a country to the database in Magento so when a user selects their country a relevant list of regions will be available in a drop down menu. To do this I believe I need to add information to directory_country_region and directory_country_region_name.
The tutorial I've been looking at states that I should add them directly to the database using sql, however I remember reading that you should not place information directly into the database using raw sql when working with Magento.
My questions are:
1- to keep in line with best practices do I need to use some magento functions to add the required information to my database or can they be dropped in using raw sql?
2- if I need to use some Magento functions how do I work out which I need to use (I have heard off and noticed the lack of documentation) or is there some online reference, even if it is limited?
3- if I am not to use a sql query why is it considered bad practice to do so in Magento?
Hello, if you want to add the information just once, you can use raw sql (faster and no drawbacks), also you are right about the 2 tables (if the country is already in directory_country). If you want to make something that will be available for more Magento instalations you have to crate a new Magento module and add the sql using the installer you can read more here http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources
Magento wiki is a good place to start, also there are lots of blog posts.
It's considered a bad practice because Magento has its own ORM and most of the time for your new tables (entities) you only need to create models that extend magento core models and you will have access to CRUD without any development and everyone that uses your new module will understaind what's going on.
Example for a region you can use the class Mage_Directory_Model_Region or for a collection of regions Mage_Directory_Model_Resource_Region_Collection

Magento user uploaded offers

Using Magento i want to create website where user can upload their products to sale, is it possible in magento ?
You can easily create a website to handle that, Magento give you an API that you can easily consume for creating products, etc ...
http://www.magentocommerce.com/wiki/doc/webservices-api/introduction
But, why not just give your users an access to their webshop Administration area?
Its better you to create module for add products by users from their my account area. Check the saveAction in Mage/Adminhtml/Controllers/Catalog/ProductController.php .You may get more idea how to save product.
If you are planning to add only some members to add their products through backend, its better you to create users and assign permissions to add products from backend.

Is it possible to customize magento admin area

We can extend the existing functionality of magento for frontend by copying modules in local area and doing some other required stuff but how I can extend or customize the magento admin area to meet my requirements without touching the core code.
For example I want to extend magento indexing functionality. During re-indexing catalog search Magento add the indexed data in catalgosearch_fulltext table and I also want to add the data to the one of the my custom database table, so that later I can look up into this database table when user search for product in my store.
Is it possible to customize magento admin area?
Please guide me.
Thanks
The preferable way to handle this is actually to override the models you want to change using Magento's class override system (both for FrontEnd and Admin changes). That way, you'll have a much easier time upgrading your Magento installations.
Sure! You can customize everything you want.
All admin related modules are in
app/code/core/Mage/Adminhtml
you can rewrite them.

Resources