Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 17 of 17
Configurable Products? 
 
gpcola
Sr. Member
 
Total Posts:  97
Joined:  2009-10-05
 

Ok I’m back with this issue again:

Call to undefined method Mage_Catalog_Model_Product_Type_Simple::getConfigurableAttributesAsArray

 
Magento Community Magento Community
Magento Community
Magento Community
 
gpcola
Sr. Member
 
Total Posts:  97
Joined:  2009-10-05
 

My problem is a little different to others mentioned in this thread perhaps in that I’m calling saveRow() from my own script that is building and maintaining a list of products, downloaded from my supplier by xml feed, in a temporary database before then using magento to add or update them in my site’s catalogue.

require_once($_SERVER['DOCUMENT_ROOT']."/app/code/local/Mage/Catalog/Model/Convert/Adapter/Productimport.php");
    
$MageProducts = new Mage_Catalog_Model_Convert_Adapter_Productimport();
    ...
    ...
    foreach(
$products as $product{
        $result 
$MageProducts->saveRow($product);
    
}

The first time I hit a configurable product I get this error but if I immediately hit refresh the script runs right past that product and all the way through to the end, passing many simple/configurable product sets on its way, without failing.

Line 107 of ProductImport.php is this line

$cspa  $product->getTypeInstance()->getConfigurableAttributesAsArray($product);

For some reason the $product->getTypeInstance is returning Mage_Catalog_Model_Product_Type_Simple but only the first time in a session?!

If I add print_r($product->getTypeInstance()) just before that line I get the following for a configurable product

Mage_Catalog_Model_Product_Type_Simple Object [_product:protected] => Mage_Catalog_Model_Product Object [_cacheTag:protected] => catalog_product [_eventPrefix:protected] => catalog_product [_eventObject:protected] => product [_canAffectOptions:protected] => [_typeInstance:protected] => Mage_Catalog_Model_Product_Type_Simple Object *RECURSION[_typeInstanceSingleton:protected] => Mage_Catalog_Model_Product_Type_Configurable Object [_usedProductAttributeIds:protected] => _cache_instance_used_product_attribute_ids....

Which is clearly wrong…

I want to be able to use my script through cron, but this error is stopping me from doing that so I desperately need some help to fix - can anyone offer some advice?

thanks -gpcola

 
Magento Community Magento Community
Magento Community
Magento Community
 
keyzo
Jr. Member
 
Total Posts:  23
Joined:  2011-02-12
 

@Diogo Barioni Abdalla I’ve followed your method and currently it’s working good, but how do you set the qty of stock per size ?

Anybody got any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
keyzo
Jr. Member
 
Total Posts:  23
Joined:  2011-02-12
 

@Diogo Barioni Abdalla I\’ve followed your method and currently it\’s working good, but how do you set the qty of stock per size ?

Anybody got any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 
plasmagunman - 22 June 2010 10:35 AM

rich15swan - 21 June 2010 02:41 AM
@neuromancer8

I am currently having the same issue what was the solution that you came across?

for me the patch of @caligola worked like a charm:
in file app/code/local/Mage/Catalog/Model/Convert/Adapter/Productimport.php find the code

if ( !empty( $usingAttributeIds ) ) {
    $product 
-> getTypeInstance() -> setUsedProductAttributeIds$usingAttributeIds );
    
$product -> setConfigurableAttributesData$product -> getTypeInstance() -> getConfigurableAttributesAsArray() );
    
$product -> setCanSaveConfigurableAttributestrue );
    
$product -> setCanSaveCustomOptionstrue );
}
and replace it with
if ( !empty( $usingAttributeIds ) ) {
    $product 
-> getTypeInstance() -> setUsedProductAttributeIds$usingAttributeIds );
    
$attributes_array $product->getTypeInstance()->getConfigurableAttributesAsArray();
    foreach(
$attributes_array as $key => $attribute_value{
        $attributes_array[$key][
'label'$attribute_value['frontend_label'];
    
}
    $product 
-> setConfigurableAttributesData($attributes_array);
    
$product -> setCanSaveConfigurableAttributestrue );
    
$product -> setCanSaveCustomOptionstrue );
}

Boss thanks it helped me lot grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
tmp2000
Jr. Member
 
Total Posts:  9
Joined:  2011-07-14
 

After a few days combination with others codes, I got the import configurable products successfully.
Please see the attached.It will be pleasure if any body use it.
Fixed the error getConfigurableAttributesAsArray not exist which as I found caused by $product->getTypeInstance()->getSetAttributes();
But don’t know the reason.
Some drawbacks:
$rootId = $store->getRootCategoryId();//Don’t know why the rootId always get 0
May be some body can help solve it.
Change the codes as following which others code supplied before :
$attr_codes[$cs_attr[’attribute_id’]] = strtolower($cs_attr[’attribute_code’]);
//$attr_codes[] = $cs_attr[’attribute_id’];

File Attachments
ProductImport.php  (File Size: 21KB - Downloads: 110)
 
Magento Community Magento Community
Magento Community
Magento Community
 
wuqio
Jr. Member
 
Total Posts:  4
Joined:  2012-10-21
 

nd to add to this, yes there should probably be some documentation. You’ve been waiting a shorter period of time than I have. And no, it won’t cover everything necessary because Magento is too flexible. The list of required import items is a moving target because attributes can be added and deleted at will and any new ones added that are created as required items need to be added to your new product import list. nike requin pas cher
nike tn requin
chaussure nike requin tn

 
Magento Community Magento Community
Magento Community
Magento Community
 
wuqio
Jr. Member
 
Total Posts:  4
Joined:  2012-10-21
 

You could use this to add multiple views but exclude is checked by default. This prevents the other product images from displaying on the product page. nike tn shopair yeezy pas cher shox nike femme noir

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 17 of 17