Exemple #1
0
 /**
  * Save data for post-category relation
  *
  * @access public
  * @param  Tech_Blog_Model_Post $post
  * @return Tech_Blog_Model_Post_Category
  * @author Ultimate Module Creator
  */
 public function savePostRelation($post)
 {
     $data = $post->getCategoriesData();
     if (!is_null($data)) {
         $this->_getResource()->savePostRelation($post, $data);
     }
     return $this;
 }
Exemple #2
0
 /**
  * Save post - product relations
  *
  * @access public
  * @param Tech_Blog_Model_Post $post
  * @param array $data
  * @return Tech_Blog_Model_Resource_Post_Product
  * @author Ultimate Module Creator
  */
 public function savePostRelation($post, $data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     $deleteCondition = $this->_getWriteAdapter()->quoteInto('post_id=?', $post->getId());
     $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
     foreach ($data as $productId => $info) {
         $this->_getWriteAdapter()->insert($this->getMainTable(), array('post_id' => $post->getId(), 'product_id' => $productId, 'position' => @$info['position']));
     }
     return $this;
 }
Exemple #3
0
 /**
  * Save post - category relations
  *
  * @access public
  * @param Tech_Blog_Model_Post $post
  * @param array $data
  * @return Tech_Blog_Model_Resource_Post_Category
  * @author Ultimate Module Creator
  */
 public function savePostRelation($post, $data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     $deleteCondition = $this->_getWriteAdapter()->quoteInto('post_id=?', $post->getId());
     $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
     foreach ($data as $categoryId) {
         if (!empty($categoryId)) {
             $insert = array('post_id' => $post->getId(), 'category_id' => $categoryId, 'position' => 1);
             $this->_getWriteAdapter()->insertOnDuplicate($this->getMainTable(), $insert, array_keys($insert));
         }
     }
     return $this;
 }