Try the Demo

Magento Forum

   
Page 2 of 3
My Magento Import & Product Management Classes
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I am going to give you an overview, but the scope of your request really lies in how OOP works.

You need to include this file in your imprort script. You need to instantiate the class by doing something like:

$product = new Product();

Then you need to cycle through each of your mysql records using a foreach…

Inside the for each set up an array of product attributes

foreach ($result as $item)
{
$data = array(
‘sku’ => $sku,
‘name’ => $name,
‘price’ => $price],
‘weight’ => $item[’weight’],
‘category_ids’ => $categoryIds,
‘style’ => $item[’model’]
);

$product->createSimpleProduct($data);
}

You are going to have to customize the class file to accept any variables that differ from what the class file uses. I contributed my exact use of this class file, but haven’t been able to find the time to make it very generic yet.

Once you learn OOP and database functions using PHP this will seem much easier. Another big hill to climb is learning how to set and get magento product attributes like price, color, etc… Let me know if you need anything else.

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael_g08
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2009-03-06
Ukraine
 

2 blakew:

I think I made it to aunderstand.
With Your help of course.

Thanx. For Your work and help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael_g08
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2009-03-06
Ukraine
 

When saving simple products script throws me error:
‘Exception’ with message ‘Notice: Undefined index: in C:\AppServ\www\magento\app\code\core\Mage\Catalog\Model\Product\Type.php on line 71’

Can’t understand why…

Please help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

Are you using 1.2.1.2?

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael_g08
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2009-03-06
Ukraine
 

Yes.

I tried to change the type of product ftom “Simple Product” to “simple”. Result is same.

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I am having the same issue, Magento has made some serious changes in this version apparently. I am looking for the necessary changes, but not having much luck. I am going to go back to an earlier version.

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael_g08
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2009-03-06
Ukraine
 

I will try to walk through the release notes and look what they changed.
If I fail I will do the same.

What is the latest version of magento Your scripts works?

P.S. The guy named resonance made a mod of Your script. Maybe it’s a point to chat with him?

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

yes i was talking to him, and he’s very knowledgable on this topic. I would be delighted if he would give us his advice, or perhaps help hunt down the issue. I will PM him to look at this forum post. I have start a thread specifically for this issue too…

http://www.magentocommerce.com/boards/viewthread/35310/

The lastest working version is 1.2.0.3. I am testing 1.2.1.1 right now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I apologize for my spelling, I am hurrying like mad right now…

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I got it!!!!!!!!!!!!!!!!!!!!

replace:

$product->setType('Simple Product');

with:

$product->setTypeId('simple');

AMAZING!

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael_g08
Sr. Member
 
Avatar
Total Posts:  108
Joined:  2009-03-06
Ukraine
 

Damn’ I be!!!

I changed ‘Simple Product’ to ‘simle’ but I didn’t know that they change method name…

Great job!!!

Thanks a lot!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I’m glad we got this resolved! smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

Hey, with the release of 1.3 all of my class stuff is broken. If you wouldn’t mind, check out:

http://www.magentocommerce.com/boards/viewthread/38379/

and let me know if anyone can help. Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
insight
Member
 
Total Posts:  56
Joined:  2008-07-24
 

Hi Blakew

Did you get this import working again for 1.3?? Also do you have it running on a daily basis to update the products?? my plan is to set it up as a cronjob to run every morning?

Thanks in advance

Pete

 Signature 

I’m advertising billabong hoodies for a client!!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
milenasecret
Jr. Member
 
Total Posts:  5
Joined:  2010-01-27
 

Could anyone plese tell me how to import values for the multiple select attribute which I have created.
The attribute code is ‘availabe_in_colors’.
I have tried using:

$product = new Mage_Catalog_Model_Product();

$product->setData(’availabe_in_colors’, array(17,18));
and
$product->setavailabe_in_colors(array(17,18));
and
$product->setavailabe_in_colors(array(’17’,’18’));

and many other versions of this code and
nothing worked.

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 3