Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Loaded7]: Product Class ID import export issue #711

Open
mattloaded opened this issue Oct 28, 2015 · 0 comments
Open

[Loaded7]: Product Class ID import export issue #711

mattloaded opened this issue Oct 28, 2015 · 0 comments

Comments

@mattloaded
Copy link

mattloaded commented Oct 28, 2015

Issue: Cannot update the product class id through product import export feature.
Fix : Updated the product products_import_export.php class file to add the feature.

File updated : admin\includes\applications\products_import_export\classes\products_import_export.php

Updated the below code,

in function getProducts($pfilter, $pgtype, $pgformat) to export the class id in txt file.
search for
$columns[] = 'categories';
$columns[] = 'parent_categories';
$columns[] = 'base_image';

Add just below,

// Add product class fields here
$columns[] = 'product_class';

// get product class
$Qclass = $lC_Database->query('select id from :table_templates_boxes where modules_group = :modules_group and code = :code');
$Qclass->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
$Qclass->bindValue(':modules_group', 'product_attributes');
$Qclass->bindValue(':code', 'product_classes');
$Qclass->execute();
// eod

search for $content .= $Qimage->value('image') . $delim;
add the following code below,

  // add class_id 
  $QclassValue = $lC_Database->query('select pc.name from :table_product_attributes pa, :table_product_classes pc where pa.products_id = :products_id and pa.id = :id and pa.value = pc.id and   languages_id in (0, :languages_id)');
  $QclassValue->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
  $QclassValue->bindTable(':table_product_classes', TABLE_PRODUCT_CLASSES);
  $QclassValue->bindInt(':products_id', $product['products_id']);
  $QclassValue->bindInt(':id', $Qclass->valueInt('id'));
  $QclassValue->bindInt(':languages_id', $product['language_id']);
  $QclassValue->execute();

  $Pclass = ($QclassValue->numberOfRows() === 1)?$QclassValue->value('name'):$lC_Language->get('text_common');
  $content .= $Pclass . $delim;

Update function importProducts()

Search for $insert_count = 0; add below,

//Class ID get template box id for attribute
$Qclass = $lC_Database->query('select id from :table_templates_boxes where modules_group = :modules_group and code = :code');
$Qclass->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
$Qclass->bindValue(':modules_group', 'product_attributes');
$Qclass->bindValue(':code', 'product_classes');
$Qclass->execute();

//EOD Class ID

search for $products_id = $product['id']; add below,

           $PclassID = 0;
    $QclassValue = $lC_Database->query('select pc.name, pc.id from :table_product_attributes pa, :table_product_classes pc where pa.id = :id and pa.value = pc.id and languages_id in (0, :languages_id) and pc.name = :name LIMIT 0 , 1');
    $QclassValue->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
    $QclassValue->bindTable(':table_product_classes', TABLE_PRODUCT_CLASSES);
    $QclassValue->bindInt(':id', $Qclass->valueInt('id'));
    $QclassValue->bindInt(':languages_id', $product['language_id']);
    $QclassValue->bindValue(':name', $product['product_class']);
    $QclassValue->execute();

    $PclassID = ($QclassValue->numberOfRows() === 1)?$QclassValue->value('id'):DEFAULT_PRODUCT_CLASSES_ID;

Search for $Qcheck = $lC_Database->query("SELECT * FROM :table_products WHERE products_id = :products_id"); and add before,

    // Product class update 
    $QcheckPA = $lC_Database->query('select pa.id from :table_product_attributes pa, :table_products p WHERE p.products_id = pa.products_id and pa.products_id = :products_id and id = :id and languages_id = :languages_id');
    $QcheckPA->bindTable(':table_products', TABLE_PRODUCTS);
    $QcheckPA->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
    $QcheckPA->bindInt(':products_id', $products_id);
    $QcheckPA->bindInt(':id', $Qclass->valueInt('id'));
    $QcheckPA->bindInt(':languages_id', $product['language_id']);
    $QcheckPA->execute();

    if($QcheckPA->numberOfRows() > 0){
      $QProductAttribute = $lC_Database->query('update :table_product_attributes set value = :value WHERE products_id = :products_id and id = :id and languages_id = :languages_id');
    }else{
      $QProductAttribute = $lC_Database->query('insert into :table_product_attributes (id, products_id, languages_id, value, value2) values (:id, :products_id, :languages_id, :value, :value2)');
      $QProductAttribute->bindInt(':value2', '0');
    }
    $QProductAttribute->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES);
    $QProductAttribute->bindInt(':products_id', $products_id);
    $QProductAttribute->bindInt(':id', $Qclass->valueInt('id'));
    $QProductAttribute->bindInt(':languages_id', $product['language_id']);
    $QProductAttribute->bindInt(':value', $PclassID);
    $QProductAttribute->execute(); 

    // eod product class 

The class column after import will be the last column in the exported sheet.
http://grabilla.com/05a19-2e38b6d6-7ffd-4ce7-9059-088eb1dcce9d.html#update

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27775867-loaded7-product-class-id-import-export-issue?utm_campaign=plugin&utm_content=tracker%2F40949&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F40949&utm_medium=issues&utm_source=github).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant