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

I want a variable (maybe static) to stores a value of any iteration importing products
 
Max134
Member
 
Total Posts:  37
Joined:  2010-05-29
 

Hi

According to this post http://www.magentocommerce.com/boards/viewthread/35865/ to make an advance dataflow, I have to make a custom adapter php file, so in app/code/core/Mage/Catalog/Model/Convert/Adapter a put this file that is like that:

class Mage_Catalog_Model_Convert_Adapter_Productwithconfigurablesandcategories
    
extends Mage_Catalog_Model_Convert_Adapter_Product
{
    
    
    
    
public function saveRow(array $importData){

   
//some code here
    
}
}

I want to put a static variable that stores all iterations. My goal is import only simple products and create configurable by code. I put this post here because is a programming question. So if I put for example a static variable like that.

class Mage_Catalog_Model_Convert_Adapter_Productwithconfigurablesandcategories
    
extends Mage_Catalog_Model_Convert_Adapter_Product
{
    
    
public static $myCount 0;
    
    public function 
saveRow(array $importData){
      self
::$myCount++;
    
}
}

In each iteration of $adapter->saveRow($importData), $myCount value is allways 1, not remember last value. If I get this works, obviously the variable it won’t be a integer, but that is not really important, what I need is a variable to remember last iteration each time saveRown function executes.

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
TreInnova
Guru
 
Avatar
Total Posts:  465
Joined:  2009-02-20
Fano
 
Max134 - 21 February 2013 07:15 AM

Hi

According to this post http://www.magentocommerce.com/boards/viewthread/35865/ to make an advance dataflow, I have to make a custom adapter php file, so in app/code/core/Mage/Catalog/Model/Convert/Adapter a put this file that is like that:



class Mage_Catalog_Model_Convert_Adapter_Productwithconfigurablesandcategories
    
extends Mage_Catalog_Model_Convert_Adapter_Product
{
    
    
    
    
public function saveRow(array $importData){

   
//some code here
    
}
}

I want to put a static variable that stores all iterations. My goal is import only simple products and create configurable by code. I put this post here because is a programming question. So if I put for example a static variable like that.

class Mage_Catalog_Model_Convert_Adapter_Productwithconfigurablesandcategories
    
extends Mage_Catalog_Model_Convert_Adapter_Product
{
    
    
public static $myCount 0;
    
    public function 
saveRow(array $importData){
      self
::$myCount++;
    
}
}

In each iteration of $adapter->saveRow($importData), $myCount value is allways 1, not remember last value. If I get this works, obviously the variable it won’t be a integer, but that is not really important, what I need is a variable to remember last iteration each time saveRown function executes.

Thanks in advance!

hi ,
can you use

class Mage_Catalog_Model_Convert_Adapter_Productwithconfigurablesandcategories
    
extends Mage_Catalog_Model_Convert_Adapter_Product
{
    
       
    
public function saveRow(array $importData){

      $_count
=         Mage::registry('mdataflow');
      
// first check if $_count is null ...
      
Mage::register('mdataflow',$_count++);

      
    
}
}
regards,
filippo.
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top