function __construct($providerName, $parent, $saved_feed)
 {
     //Owner allows ancestor to communicate with parent
     $this->owner = $parent;
     $this->loadDropDownMappings($providerName);
     if ($saved_feed == null || $saved_feed->own_overrides != 1) {
         $this->loadAdvancedCommands($providerName);
     } else {
         $this->advancedCommands = explode("\n", $saved_feed->feed_overrides);
     }
     $recent_attribute = null;
     //Allows setParam to work
     foreach ($this->advancedCommands as $this_option) {
         //$xyz 			means single setting true or = something
         //x = y			means custom mapping (my field to given attribute)
         //x = $y			means custom mapping (my field to fixed value y)
         $this_option = trim($this_option);
         if (strlen($this_option) == 0) {
             continue;
         }
         if ($this_option[0] == ';') {
             continue;
         }
         //is a comment
         if ($this_option[0] == '#') {
             continue;
         }
         //is a comment
         if ($this_option[0] == '/' && $this_option[1] == '/') {
             continue;
         }
         //is a comment
         //Try to find a command if there is one
         $command = '';
         if (substr($this_option, 0, 1) == '$') {
             $command = '$';
         } else {
             $params = $this->ptokens($this_option);
             $command = strtolower($params[0]);
         }
         //Apply command
         switch ($command) {
             case '$':
                 //Mapping 2.0 setting
                 $this->interpretSingleSetting($this_option, $parent);
                 break;
             case 'deleteattribute':
                 //If the Attribute doesn't exist (yet), map it first.
                 //This allows variable-attribute feeds to have attributes deleted since their attribute mappings might not yet be complete
                 if ($params[1] == '*') {
                     foreach ($parent->attributeMappings as $thisAttributeMapping) {
                         $thisAttributeMapping->deleted = true;
                     }
                     if (isset($parent->mapAttributesOnTheFly)) {
                         $parent->mapAttributesOnTheFly = false;
                     }
                 } else {
                     if ($parent->getMapping($params[1]) == null) {
                         $parent->addAttributeMapping($params[1], $params[1]);
                     }
                     //Delete it
                     $parent->getMapping($params[1])->deleted = true;
                 }
                 break;
             case 'deletelicensekeys':
                 $reg = new PLicense();
                 $reg->unregisterAll();
                 break;
             case 'limitoutput':
                 if (strtolower($params[1]) == 'from' && isset($params[4])) {
                     $parent->has_product_range = true;
                     $parent->product_limit_low = $params[2];
                     $parent->product_limit_high = $params[4];
                 } elseif (strtolower($params[1]) == 'to' && isset($params[2])) {
                     $parent->has_product_range = true;
                     $parent->product_limit_low = 0;
                     $parent->product_limit_high = $params[2];
                 }
                 break;
             case 'mapattribute':
                 $usesCData = false;
                 if (isset($params[4]) && strtolower($params[4]) == 'true') {
                     $usesCData = true;
                 }
                 $recent_attribute = $parent->addAttributeMapping($params[1], $params[3], $usesCData, false, true);
                 break;
             case 'rule':
             case 'addrule':
                 //Rule name after last ")"
                 $ruleName = '';
                 for ($i = count($params) - 3; $i > 0; $i--) {
                     if ($params[$i] == ')') {
                         $ruleName = $params[$i + 2];
                         break;
                     }
                 }
                 if (strtolower($ruleName) == 'substring') {
                     $ruleName = 'substr';
                 }
                 //Rule Parameters is everything within ()
                 $start = false;
                 $ruleParams = array();
                 foreach ($params as $param) {
                     if ($param == ')') {
                         break;
                     }
                     if ($start) {
                         $ruleParams[] = $param;
                     }
                     if ($param == '(') {
                         $start = true;
                     }
                 }
                 $parent->addRule($ruleName, $params[1], $ruleParams, 100);
                 break;
             case 'set':
                 //Eg: set forceCData to off
                 if (count($params) > 3) {
                     if (strtolower($params[3]) == 'false') {
                         $params[3] = false;
                     }
                     if (strtolower($params[3]) == 'true') {
                         $params[3] = true;
                     }
                     if (strtolower($params[3]) == 'no') {
                         $params[3] = false;
                     }
                     if (strtolower($params[3]) == 'yes') {
                         $params[3] = true;
                     }
                     if (strtolower($params[3]) == 'off') {
                         $params[3] = false;
                     }
                     if (strtolower($params[3]) == 'on') {
                         $params[3] = true;
                     }
                     if ($this->validIdentifier($params[1])) {
                         $parent->{$params}[1] = $params[3];
                     }
                 }
                 break;
             case 'maptaxonomy':
                 //Example: mapTaxonomy product_brand to brand
                 $parent->relatedData[] = array($params[1], $params[3]);
                 break;
             case 'setattribute':
                 if (strtolower($params[2]) == 'mapto') {
                     if ($parent->getMapping($params[1]) != null) {
                         $recent_attribute = $parent->getMapping($params[1]);
                         $recent_attribute->mapTo = $params[3];
                     }
                 }
                 if (strtolower($params[2]) == 'default') {
                     if (isset($params[4])) {
                         $defaultClass = $params[4];
                     } else {
                         $defaultClass = 'PAttributeDefault';
                     }
                     $parent->addAttributeDefault($params[1], $params[3], $defaultClass);
                     //This option is the same as setattributedefault
                 }
                 break;
             case 'setattributedefault':
                 if (isset($params[4])) {
                     $defaultClass = $params[4];
                 } else {
                     $defaultClass = 'PAttributeDefault';
                 }
                 $parent->addAttributeDefault($params[1], $params[3], $defaultClass);
                 break;
             case 'setattributeparam':
                 //For example, allows AmazonSC to set the localized name after mapAttribute [This equals setParam but allows you to specify which mapping]
                 //eg: setAttributeParam description usesCData true
                 $recent_attribute = $parent->getMapping($params[1]);
                 if ($recent_attribute != null) {
                     $recent_attribute->{$params}[2] = $params[3];
                 }
                 break;
             case 'setlicensekey':
                 $reg = new PLicense();
                 $reg->setLicenseKey($params[1]);
                 break;
             case 'setparam':
                 //For example, allows AmazonSC to set the localized name after mapAttribute
                 //eg setParam localized_name "A local name"
                 if ($recent_attribute != null) {
                     $recent_attribute->{$params}[1] = $params[2];
                 }
                 break;
             case 'setrapidcarttoken':
                 global $pfcore;
                 $pfcore->settingSet('cp_rapidcarttoken', $params[1]);
                 break;
             default:
                 //Mapping 2.0 override
                 $this->interpretOverride($this_option);
         }
     }
 }