Loaded Commerce Community

Banner


Board index » Loaded Commerce Support » General Support

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Easypopulate Advanced Modifications
PostPosted: Sat Jan 07, 2012 7:42 am 
Offline
CRE Newbie

Joined: Sat Jan 07, 2012 6:03 am
Posts: 4
Hi Guys,

I am currently modifying easypopulate advanced to add extra fields, all was going to plan until I hit problems with the products_description table.

No matter what I do I can not get the new field in the products_description table to update correctly, maybe I am not seeing the whole picture with regards to the way languages are handled.

Has anyone managed to modify this part of EPA successfully and can offer advice. I have googled but can not find anything relating to this issue.

I am quite happy to post the code if required.

Thanks for looking (and hopefully helping out)

Thanks

Mark


Top
 Profile  
 
 Post subject: Re: Easypopulate Advanced Modifications
PostPosted: Sat Jan 07, 2012 6:21 pm 
Offline
CRE Legend
User avatar

Joined: Thu Jun 12, 2008 6:39 am
Posts: 2404
Location: New Zealand
What are you trying to add? Example would help.

Simon

_________________
www.codemehappy.com
For Cre Loaded tips, how-to articles and more


Top
 Profile  
 
 Post subject: Re: Easypopulate Advanced Modifications
PostPosted: Sat Jan 07, 2012 7:12 pm 
Offline
CRE Newbie

Joined: Sat Jan 07, 2012 6:03 am
Posts: 4
Hi mate, thanks for looking

the field I am trying to add is called mediacat_part_no

I think I have got all the sections of code covered where it needs to be added.

Code:
while ($row){
    // OK, since we got a row, the item already exists.
    // Let's get all the data we need and fill in all the fields that need to be defaulted to the current values
    // for each language, get the description and set the vals
    foreach ($langcode as $key => $lang){
      $sql2 = "SELECT *
        FROM ".TABLE_PRODUCTS_DESCRIPTION."
        WHERE
          products_id = " . $row['v_products_id'] . " AND
          language_id = '" . $lang['id'] . "'
        ";
      $result2 = tep_db_query($sql2);
      $row2 =  tep_db_fetch_array($result2);
                        // Need to report from ......_name_1 not ..._name_0
      $row['v_products_name_' . $lang['id']]    = $row2['products_name'];
      $row['v_products_description_' . $lang['id']]   = $row2['products_description'];

      $row['v_mediacat_part_no_' . $lang['id']]   = $row2['mediacat_part_no'];

      $row['v_products_url_' . $lang['id']]     = $row2['products_url'];

      // support for  Header Controller 2.1 here
      if(isset($filelayout['v_products_head_title_tag_' . $lang['id'] ])){
        $row['v_products_head_title_tag_' . $lang['id']]  = $row2['products_head_title_tag'];
        $row['v_products_head_desc_tag_' . $lang['id']]   = $row2['products_head_desc_tag'];
        $row['v_products_head_keywords_tag_' . $lang['id']]   = $row2['products_head_keywords_tag'];
      }
      // end support for Header Controller 2.0
    }


Code:
// Begin writting new data to current data

  // this is an important loop.  What it does is go thru all the fields in the incoming file and set the internal vars.
  // Internal vars not set here are either set in the loop above for existing records, or not set at all (null values)
  // the array values are handled separatly, although they will set variables in this loop, we won't use them.
  foreach( $filelayout as $key => $value ){
    $$key = $items[ $value ];
  }
  // so how to handle these?  we shouldn't built the array unless it's been giving to us.
  // The assumption is that if you give us names and descriptions, then you give us name and description for all applicable languages
  foreach ($langcode as $lang){
    $l_id = $lang['id'];
    if (isset($filelayout['v_products_name_' . $l_id ])){
      //we set dynamically the language values
      $v_products_name[$l_id]   = tep_db_encoder($items[$filelayout['v_products_name_' . $l_id]]);
      $v_products_description[$l_id]  = tep_db_encoder($items[$filelayout['v_products_description_' . $l_id ]]);
      $v_mediacat_part_no = tep_db_encoder($items[$filelayout['v_mediacat_part_no']]);
      $v_products_url[$l_id]    = $items[$filelayout['v_products_url_' . $l_id ]];
      $v_products_head_title_tag[$l_id]   = $items[$filelayout['v_products_head_title_tag_' . $l_id]];
      $v_products_head_desc_tag[$l_id]  = $items[$filelayout['v_products_head_desc_tag_' . $l_id]];
      $v_products_head_keywords_tag[$l_id]  = $items[$filelayout['v_products_head_keywords_tag_' . $l_id]];
    }
  }


Code:
    // the following is common in both the updating an existing product and creating a new product
    if ( isset($v_products_name)){
      foreach( $v_products_name as $key => $name){
        if ($name!=''){
          $sql = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE
              products_id = $v_products_id AND
              language_id = " . $key;
          $result = tep_db_query($sql);
          if (tep_db_num_rows($result) == 0) {
            // nope, this is a new product description
            $result = tep_db_query($sql);
            $sql =
              "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."
                (products_id,
                language_id,
                products_name,
                products_description,
                mediacat_part_no,
                products_url,
                products_head_title_tag,
                products_head_desc_tag,
                products_head_keywords_tag)
                VALUES (
                  '" . $v_products_id . "',
                  " . $key . ",
                  '" . $name . "',
                  '". $v_products_description[$key] . "',
                  '". $v_mediacat_part_no[$key] . "',
                  '". $v_products_url[$key] . "',
                  '". $v_products_head_title_tag[$key] . "',
                  '". $v_products_head_desc_tag[$key] . "',
                  '". $v_products_head_keywords_tag[$key] . "')";
            $result = tep_db_query($sql);
          } else {
            // already in the description, let's just update it
            $sql =
              "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET
                products_name='$name',
                products_description='".$v_products_description[$key] . "',
                mediacat_part_no='" . $v_mediacat_part_no[$key] . "',
                products_url='" . $v_products_url[$key] . "',
                products_head_title_tag = '" . $v_products_head_title_tag[$key] ."',
                products_head_desc_tag = '" . $v_products_head_desc_tag[$key] ."',
                products_head_keywords_tag = '" . $v_products_head_keywords_tag[$key] ."'
              WHERE
                products_id = '$v_products_id' AND
                language_id = '$key'";

            $result = tep_db_query($sql);
          }
        }
      }
    }


Top
 Profile  
 
 Post subject: Re: Easypopulate Advanced Modifications
PostPosted: Sat Jan 07, 2012 10:04 pm 
Offline
CRE Legend
User avatar

Joined: Thu Jun 12, 2008 6:39 am
Posts: 2404
Location: New Zealand
Try changing in your second block, this:
Code:
$v_mediacat_part_no = tep_db_encoder($items[$filelayout['v_mediacat_part_no']]);

to this:
Code:
$v_mediacat_part_no[$l_id] = tep_db_encoder($items[$filelayout['v_mediacat_part_no_' . $l_id]]);

EPA imports are a 2 step thing - upload (first option) then insert from /temp (third option)

Simon

_________________
www.codemehappy.com
For Cre Loaded tips, how-to articles and more


Top
 Profile  
 
 Post subject: Re: Easypopulate Advanced Modifications
PostPosted: Sun Jan 08, 2012 4:54 am 
Offline
CRE Newbie

Joined: Sat Jan 07, 2012 6:03 am
Posts: 4
Hi Simon,

The way I had the code did work (sort of) although it uploaded incorrect values to the incorrect field.

I changed the code as suggested and now it just uploads 0 to all fields in mediacat_part_no

Regards

Mark


Top
 Profile  
 
 Post subject: Re: Easypopulate Advanced Modifications
PostPosted: Sun Jan 08, 2012 5:28 am 
Offline
CRE Newbie

Joined: Sat Jan 07, 2012 6:03 am
Posts: 4
Thanks Simon,

I have now sorted it out, the last piece of the puzzle was that I missed out the _1 from the field name in the csv :oops:

Thanks

Mark


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

Board index » Loaded Commerce Support » General Support

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
It is currently Wed May 23, 2012 8:37 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Login

Forums Latest Activity

Top Listing

1. Cart2Cart - Shopping...
    Category: Shopping Cart Database Conversion Scripts
    
2. Points & Rewards PLUS!...
    Category: Add-Ons
    
3. Configuration Server...
    Category: Fixes
    
4. Credit Card with CCV
    Category: Payment Modules
    
5. CC7333_ATS
    Category: Templates
    
Show more...

© CRE Loaded is a product of Chain Reaction Ecommerce, Inc. Usage & Privacy Policy