Set default product type as "Affiliate Product"

WordPress Business Themes Forums General Discussion Set default product type as "Affiliate Product"

Set default product type as "Affiliate Product"

September 22, 2017
 Martin

  • Martin
    Newbie 12 points

    I’m using the latest Responsive Shop Theme with the new Watch child theme and the Amazon import plugin. Is there a way to set the default “product type” to “Affiliate Product” so that I don’t have to change each product individually after I import it?

    September 22, 2017 at 4:25 pm
  • JamesD
    JamesD
    Titan 758 points

    Hello Martin,

    Go to “Toolbox > Listing Changes” and at the very bottom you should see “Set All Product Type (Affiliate Product)” text with a button to update all listings.

    Is that what you’re needing?

    Note: To have it done automagically during import then a change to the plugin core file would need to be edited.

    September 26, 2017 at 1:35 am

  • Martin
    Newbie 12 points

    That’s what I needed, thanks. However, when I use it I get this message:

    “Warning: mysql_query() expects parameter 2 to be resource, object given in /………………/wp-content/themes/ST/framework/admin/_4.php on line 250
    on line: 250”

    September 26, 2017 at 6:08 pm
  • JamesD
    JamesD
    Titan 758 points

    Hmmm.
    Looks like the WP DB handle is invalid/empty. It may have to do with using mysqli functions. If it is, then I’m sure it’ll already be handled in any new PP theme versions.

    The only way I see to correct it right now is to alter a core file, so be careful (/ST/framework/admin/_4.php).

    First, make a backup copy of the file. Open up the file and around line #247 you’ll see:
    case "set8": {

    Select everything in between the “case “set8″: {” and the line
    echo "<h1>Products Updated</h1>"; (around line #255)

    Replace the code between those 2 points with the following:

    $SQL = "SELECT ".$wpdb->posts.".ID FROM ".$wpdb->posts." WHERE ".$wpdb->posts.".post_type = ('".THEME_TAXONOMY."_type') LIMIT 0,200";
    $result = mysqli_query($wpdb->dbh, $SQL) or die(mysqli_error().' on line: '.__LINE__);
    if (mysqli_num_rows($result) > 0) {while ($val = mysqli_fetch_object($result)){
    	update_post_meta($val->ID,'type',2);
    } }
    

    When you’ve made the change that section would look like:

    case "set8": {		
    		
    $SQL = "SELECT ".$wpdb->posts.".ID FROM ".$wpdb->posts." WHERE ".$wpdb->posts.".post_type = ('".THEME_TAXONOMY."_type') LIMIT 0,200";
    $result = mysqli_query($wpdb->dbh, $SQL) or die(mysqli_error().' on line: '.__LINE__);
    if (mysqli_num_rows($result) > 0) {while ($val = mysqli_fetch_object($result)){
    	update_post_meta($val->ID,'type',2);
    } }
    					
    echo "<h1>Products Updated</h1>";

    Note: Since it is a core file, it may be overwritten during a theme upgrade, so you may need to redo these steps if it’s not working in the updated theme by then.

    September 26, 2017 at 7:37 pm
    This reply was awarded the best answer by the topic poster.

  • Martin
    Newbie 12 points

    That’s great, thank you very much.

    September 26, 2017 at 10:05 pm
  • JamesD
    JamesD
    Titan 758 points

    My pleasure, glad it helped. Thanks for updating!

    September 26, 2017 at 10:31 pm
Viewing 6 posts - 1 through 6 (of 6 total)

Didn't find what you were after?

Chat with us now

or contact our support team