Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Product Option Variant Status Export - Csv Rate Topic   - - - - -

 

Posted 22 February 2021 - 06:23 PM #1

Greetings, we are using an older version of CS-Cart (4.7.3), and the Product Export Option Variant "Status" field is not included in the CSV ([A]ctive or [D]isabled), so I was hoping to get that field to export.  The CSV Import for the status works just fine if you add "///status=D within the Option Variant, but we need to know which ones are disabled to begin with, otherwise the import will activate all of the Option Variants. 

 

Here is what I tried - and thought it would be simple - code changes at // area:

FILE: \app\schemas\exim\products.functions.php

 

if (floatval($v['modifier']) != 0) {
                        $variant .= $features_delimiter . 'modifier=' . $v['modifier'];
                        $variant .= $features_delimiter . 'modifier_type=' . $v['modifier_type'];
                    }
 
                    if (floatval($v['weight_modifier']) != 0) {
                        $variant .= $features_delimiter . 'weight_modifier=' . $v['weight_modifier'];
                        $variant .= $features_delimiter . 'weight_modifier_type=' . $v['weight_modifier_type'];
                    }
 
// START - Add Variant Status
   //  I TRIED ADDING THIS - did not work - blank value --->       $variant .= $features_delimiter . 'status=' . $v['status'];
 
   // ALSO ADDED THIS and it works fine --->                    $variant .= $features_delimiter . 'position=' . $v['position'];
// END - Add Variant Status
 
                    if (!empty($v['image_pair']['image_id'])) {
                        $variant .= $features_delimiter . 'image=' . fn_exim_export_image($v['image_pair']['image_id'], 'variant_image', '', false);
                    }
 
I thought that would do the trick, but $v['status'] apparently has no value there, and I'm having a bit of trouble finding how to get that value if it isn't already set somewhere else - I'm trying to keep the code quick and clean since I want it to be monsterously scalable if the cart has tons of products with options.
 
Any information would be greatly appreciated!!  Thanks!
 
Here is what the Exported CSV Product Option cell looks like with the "position" field also added in:
(CS-CART) OPTION-1: S[OP-1-Variant-1///position=10,OP-1-Variant-2///modifier=25.000///modifier_type=A///position=20]///inventory=N///missing_variants_handling=M///multiupload=N///required=Y///status=A; (CS-CART) OPTION-2: S[OP-1-Variant-1///position=10,OP-1-Variant-2///modifier=50.400///modifier_type=A///position=20,OP-1-Variant-3///modifier=17.100///modifier_type=A///position=30]///inventory=N///missing_variants_handling=M///multiupload=N///required=Y///status=A
 
Side note - if you add ///status=D to the OP-1-Variant-2 section (see below), it will Disable that Variant if you Import the CSV file - otherwise if status is not set, all Variants seem to be set to Active (I just noticed this recently since we never really Disabled a Option Variant (usually just deleted it), the Option "status" is all we ever used and that works fine on Export and Import.  Option "status" and Option Variant "status" are two different things (just FYI)

(CS-CART) OPTION-1: S[OP-1-Variant-1///position=10,OP-1-Variant-2///modifier=25.000///modifier_type=A///position=20///status=D]///inventory=N///missing_variants_handling=M///multiupload=N///required=Y///status=A; (CS-CART) OPTION-2: S[OP-1-Variant-1///position=10,OP-1-Variant-2///modifier=50.400///modifier_type=A///position=20,OP-1-Variant-3///modifier=17.100///modifier_type=A///position=30]///inventory=N///missing_variants_handling=M///multiupload=N///required=Y///status=A



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12072 posts

Posted 22 February 2021 - 07:20 PM #2

Looks to me like 'status' should already be there (at least in current version).  You might check yours to see if it's the same as this:

function fn_exim_get_option_attrs()
{
    $export_fields = array(
        'allowed_extensions',
        'inventory',
        'max_file_size',
        'missing_variants_handling',
        'multiupload',
        'required',
        'status'
    );

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 22 February 2021 - 07:43 PM #3

Thanks for the response.  Yes, that area in the new version is the same as in mine - I'm guessing this is maybe for the Product Option, and Product Option Variant declaration is somewhere else?

 

Line 514:

function fn_exim_get_option_attrs()
{
    $export_fields = array(
        'allowed_extensions',
        'inventory',
        'max_file_size',
        'missing_variants_handling',
        'multiupload',
        'required',
        'status'
    );


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12072 posts

Posted 22 February 2021 - 07:51 PM #4

Most likely missing from some variants section.  But you should be able to either add it to a function that returns the variant attributes or via the base schema itself if a function isn't used.

 

But given I didn't even know that option variants had a status, not sure what further help I can be.  Not something I've encountered before.

 

Good luck.  Sometimes things that seem like they should be simple are most certainly not! :-)


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 23 February 2021 - 03:15 PM #5

Thanks, I'll keep digging!  We haven't really disabled them before either, so I never tested full functionality or even noticed the stock export/import for the "disabled" option variants sets them to "active" by default (if not specifically set to "///status=D" in the import) if exporting and re-importing the "Options" field on a product that is new to that option. It may not overide the status field if the option already exists(?) (I haven't tested that yet to know for sure)

Just glad we caught it somewhat early with us using "disabled" option variants.  CSV import and export is a lifesaver when dealing with 1000's of products...  :)