Magmi Datapump API - Item not showing in store - magento

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.

Related

Magento enterprise edition indexing

Does magento enterprise edition needs cron to be set in order to run Indexing the following process.
URL Redirects
Stock Status
Catalog Search Index
Product URL Rewrites
Category URL Rewrites
Catalog Category/Product Index
Catalog product price
I have flat catalog for category enabled, but whenever I modify category attributes like meta data, the changes are not getting reflected in the front end. But whenever I disable flat catalog for category, the changes are reflected. Please guide.
There are 2 ways of configuring it in magento. One way will require crons to be set to run.
To configure it go to : System > Configuration > Advanced > Index Management
You can here configure if you wish the indexes to be updated on save or when scheduled
The on save process will slow down the update & creation of products. But as indicated will update every-thing when you modify a product in the Back office.
The scheduled uses MYSQL Triggers to detect changes and with the cron will update the flat tables that needs updating.

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 imported products with magmi are not visible on the website

I have a CSV file and it takes ages to import it with magento standard interface, import is ok. I tried to use open source solution called "Magmi" which imports the same file in seconds when magento takes days. The problem is that if the file is imported with magmi, products are not visible on the website, even though they show in admin panel. Does somebody know the CSV structure (obligatory fields) for a successful Magmi import to happen?
You need to reindex (System -> Index Management) after importing with magmi: not sure exactly which indexes are required, one I know for sure is Product Flat Data, even if you don't use the flat catalog.
As for the csv structure, export all products to have an example.
magmi automatically indexes "Category Products" (catalog_category_product) and "Catalog URL Rewrites" (catalog_url), but only if you use the "on the fly" indexer plugin. However, in order for the products to show up on the frontend, you need to run the "product price" indexer (catalog_product_price). It's one of the quickest indexes, so a full reindex is overkill, specially if you have many products.
remember you can execute the reindexing via command line to save some time. Inside /magento/shell/ execute
php indexer.php --reindex catalog_product_price
Just type "php indexer.php" and you'll get a list of available commands.

Ability to connect Magento to existing database?

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.

Resources