Magento: Importing / updating LOTS of products via cron job?

Arnie

I am trying to import / update 10000+ products into Magento 1.9 from a given XML file (no Magento import format). This is the current workflow:

In a cron job I am downloading a XML file every night at 1 am. This file includes the 10000+ products. So I am going through the XML file using the XMLReader class from PHP. To figure out if a product already exists, I am first loading the product by sku, like this and after that I am checking if it was loaded, like this:

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
if(!$product) { 
    // create the product
} else {
    // update the product
}

Of course this is not the only code, but maybe its my bottleneck? The code is running forever the way I have it written right now. Any ideas on how to quickly (within 3-4 hours maybe) import 10000+ products?

I can't use magmi or the import workflow because the import has to run at night via cron job.

Thanks!

Matt O

First, regarding the product entity storage in the database: everything is stored using the EAV pattern, which means you can add arbitrary attributes to your product entity and they're treated as being roughly equivalent to another column on the product table. However, they're actually stored across a set of tables which then have to be joined up whenever you request a product model (so you're joining across several large tables, 10000+ times).

Luckily there's a way around this in the form of flat tables - these are tables which take the custom attributes and create a single table which incorporates all of the product attributes (which are configured with the "Use in Product Listing" option). Your bottleneck is probably that you're not using this product flat table (enable it in System configuration under the Catalog section). It should re-build the flat table automatically after being turned on, if not you'll need to reindex manually from Index Management.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Magento indexer running via ssh but not cron job

From Dev

Issue with importing products in magento

From Dev

Magento cron job not working

From Dev

Cron Job issue Magento

From Dev

Error importing csv products in magento

From Dev

Cron job not working: importing to calcurse

From Dev

Integrity constraint violation while importing products in magento

From Dev

Magento add custom options with programmatically importing products

From Dev

Magento products not showing in backend after importing Magento 1.3 products to Magento 1.9

From Dev

Magento products not showing in backend after importing Magento 1.3 products to Magento 1.9

From Dev

Create Magento cron job task programmatically

From Dev

How to set up a cron job in Magento

From Dev

Magento Cron Job Error - Invalid Callback

From Dev

Magento - cron job script is running, but Magento order confirmation emails are not sending

From Dev

how to use correctly semicolon when importing products in Magento with CSV

From Dev

how to use correctly semicolon when importing products in Magento with CSV

From Dev

Python script to backup directory via Cron job

From Dev

php exec() not running via a cron job

From Dev

Can Ubuntu play a video via cron job?

From Dev

Shell script is not working via cron job

From Dev

Python script to backup directory via Cron job

From Dev

How to delete one cron job via SSH?

From Dev

Add cron job via single command

From Dev

php exec() not running via a cron job

From Dev

Facebook Pages: Posting to page via cron job

From Dev

cron job is working in magento site- But No heartbeat found

From Dev

Magento PHP cron job fail to open required php files

From Dev

PHPMailer- Should I send emails in runtime, or via cron job?

From Dev

Flask Webpage Via Cron Job - url_for call broken

Related Related

  1. 1

    Magento indexer running via ssh but not cron job

  2. 2

    Issue with importing products in magento

  3. 3

    Magento cron job not working

  4. 4

    Cron Job issue Magento

  5. 5

    Error importing csv products in magento

  6. 6

    Cron job not working: importing to calcurse

  7. 7

    Integrity constraint violation while importing products in magento

  8. 8

    Magento add custom options with programmatically importing products

  9. 9

    Magento products not showing in backend after importing Magento 1.3 products to Magento 1.9

  10. 10

    Magento products not showing in backend after importing Magento 1.3 products to Magento 1.9

  11. 11

    Create Magento cron job task programmatically

  12. 12

    How to set up a cron job in Magento

  13. 13

    Magento Cron Job Error - Invalid Callback

  14. 14

    Magento - cron job script is running, but Magento order confirmation emails are not sending

  15. 15

    how to use correctly semicolon when importing products in Magento with CSV

  16. 16

    how to use correctly semicolon when importing products in Magento with CSV

  17. 17

    Python script to backup directory via Cron job

  18. 18

    php exec() not running via a cron job

  19. 19

    Can Ubuntu play a video via cron job?

  20. 20

    Shell script is not working via cron job

  21. 21

    Python script to backup directory via Cron job

  22. 22

    How to delete one cron job via SSH?

  23. 23

    Add cron job via single command

  24. 24

    php exec() not running via a cron job

  25. 25

    Facebook Pages: Posting to page via cron job

  26. 26

    cron job is working in magento site- But No heartbeat found

  27. 27

    Magento PHP cron job fail to open required php files

  28. 28

    PHPMailer- Should I send emails in runtime, or via cron job?

  29. 29

    Flask Webpage Via Cron Job - url_for call broken

HotTag

Archive