Esempio n. 1
0
 /**
  * @since 1.9.0.1
  *
  * @param DIWikiPage $subject
  */
 protected function dispatchUpdateForSubject(DIWikiPage $subject)
 {
     Profiler::In(__METHOD__, true);
     $this->addUpdateJobsForProperties($this->store->getProperties($subject));
     $this->addUpdateJobsForProperties($this->store->getInProperties($subject));
     $this->addUpdateJobsFromSerializedData();
     Profiler::Out(__METHOD__, true);
     return $this;
 }
Esempio n. 2
0
 /**
 * Override modResourceUpdateProcessor::beforeSave to provide custom functionality, saving settings for the container
 * to a custom field in the DB.
 *
 * The Post data comes thru flattened (boo)
 *
        [specs_4] => on
        [specs_12] => on
        [taxonomies_3] => on
        [taxonomies_4] => on
        [variations_1] => Option Only
        [variations_2] => Variant
        [variations_3]
 * On the flip side, it should be available in JS via this path: MODx.activePage.config.record.properties.moxycart
 *
 * {@inheritDoc}
 * @return boolean
 */
 public function beforeSave()
 {
     $raw = $this->getProperties();
     // <-- this will have raw values
     $properties = $this->object->getProperties('moxycart');
     //<-- we need to update these values
     $this->object->set('class_key', 'Store');
     //$this->modx->log(1,'beforeSave raw values: '.print_r($raw,true));
     //$this->modx->log(1,'existing values: '.print_r($properties,true));
     //$this->modx->log(1,'beforeSave raw POST values: '.print_r($_POST,true));
     $properties['product_type'] = $this->modx->getOption('product_type', $raw);
     $properties['product_template'] = $this->modx->getOption('product_template', $raw);
     $properties['track_inventory'] = $this->modx->getOption('track_inventory', $raw) == 'Yes' ? 1 : 0;
     $properties['sort_order'] = $this->modx->getOption('sort_order', $raw);
     $properties['qty_alert'] = $this->modx->getOption('qty_alert', $raw);
     // Fresh start...
     $properties['specs'] = array();
     $properties['taxonomies'] = array();
     $properties['variations'] = array();
     foreach ($raw as $k => $v) {
         $len = strlen($k);
         if ($this->starts_with($k, 'specs')) {
             $properties['specs'][substr($k, 6 - $len)] = true;
         }
         if ($this->starts_with($k, 'taxonomies')) {
             $properties['taxonomies'][substr($k, 11 - $len)] = true;
         }
         if ($this->starts_with($k, 'variations')) {
             $properties['variations'][substr($k, 11 - $len)] = $v;
         }
     }
     $this->object->setProperties($properties, 'moxycart');
     return parent::beforeSave();
 }