Esempio n. 1
0
 public function save()
 {
     //before save
     if (empty($this->created_on)) {
         $this->created_on = Axis_Date::now()->toSQLString();
     }
     $this->modified_on = Axis_Date::now()->toSQLString();
     if (empty($this->date_available)) {
         $this->date_available = new Zend_Db_Expr('NULL');
     }
     if (empty($this->manufacturer_id)) {
         $this->manufacturer_id = new Zend_Db_Expr('NULL');
     }
     if (empty($this->ordered)) {
         $this->ordered = 0;
     }
     if (empty($this->viewed)) {
         $this->viewed = 0;
     }
     if (empty($this->tax_class_id)) {
         $this->tax_class_id = new Zend_Db_Expr('NULL');
     }
     return parent::save();
 }
Esempio n. 2
0
 /**
  * @return mixed The primary key value(s), as an associative array if the
  *     key is compound, or a scalar if the key is single-column.
  */
 public function save()
 {
     //before save
     //auto generate order number
     if (null === $this->number) {
         $this->number = md5(time());
         $id = parent::save();
         $prefix = Axis::config('sales/order/order_number_pattern_prefix');
         $numberPattern = Axis::config('sales/order/order_number_pattern');
         $this->number = $prefix . (strlen($numberPattern) > strlen($id) ? substr($numberPattern, 0, strlen($numberPattern) - strlen($id)) . $id : $id);
     }
     return parent::save();
 }
Esempio n. 3
0
 /**
  *
  * @param type $type
  * @param type $name
  * @param type $content
  * @param type $url
  * @param type $imagePath
  * @param type $imageTitle
  * @return Zend_Search_Lucene_Document 
  */
 public function getDocument(Axis_Db_Table_Row $row)
 {
     $document = new Zend_Search_Lucene_Document();
     if ($row instanceof Axis_Cms_Model_Page_Content_Row) {
         $type = 'page';
         $name = $row->title;
         $content = $row->getContent();
         $url = $row->link;
     } else {
         $type = 'product';
         $name = $row->name;
         $content = $row->description;
         $url = $row->key_word;
         $imagePath = $row->image_thumbnail;
         $imageTitle = $row->image_title;
         $document->addField(Zend_Search_Lucene_Field::Text('sku', $row->sku, $this->_encoding));
         $document->addField(Zend_Search_Lucene_Field::UnIndexed('image', $imagePath, $this->_encoding));
         $document->addField(Zend_Search_Lucene_Field::UnIndexed('image_title', $imageTitle, $this->_encoding));
     }
     $document->addField(Zend_Search_Lucene_Field::UnIndexed('type', $type, $this->_encoding));
     $document->addField(Zend_Search_Lucene_Field::Text('name', $name, $this->_encoding));
     $document->addField(Zend_Search_Lucene_Field::Text('contents', $content, $this->_encoding));
     $document->addField(Zend_Search_Lucene_Field::Text('url', $url, $this->_encoding));
     return $document;
 }