Example #1
0
 public function setTagsArray(array $data)
 {
     // reset dei tag per semplificare lo script
     ProductTag::model()->deleteAll('product=:p', array(':p' => $this->id));
     // data attuale
     $now = new DateTime();
     $timestamp = $now->format('Y-m-d H-i-s');
     // ricerca dei tag e creazione dei link
     foreach ($data as $tagName) {
         $tag = Tag::model()->find('name=:nm', array(':nm' => $tagName));
         /** @var Tag $tag */
         if ($tag == null) {
             $tag = new Tag();
             $tag->name = $tagName;
             $tag->description = ucwords($tagName);
             $tag->timestamp = $timestamp;
             $tag->insert();
         }
         $productTag = ProductTag::model()->find('product=:p AND tag=:t', array(':p' => $this->id, ':t' => $tag->id));
         /** @var ProductTag $productTag */
         if ($productTag == null) {
             $productTag = new ProductTag();
             $productTag->product = $this->id;
             $productTag->tag = $tag->id;
             $productTag->insert();
         }
     }
 }
 public function getFilterTagsAction()
 {
     $show_view = false;
     $front = Zend_Controller_Front::getInstance();
     if ($front->getRequest()->getParam('controller') == 'category') {
         $cat_id = $front->getRequest()->getParam('cat_id');
         if ($cat_id) {
             $Category = new Category();
             $category = $Category->get($cat_id);
             if (trim($category['children']) == $cat_id) {
                 $ProductTag = new ProductTag();
                 $filter_tags = $ProductTag->get_top_popular($cat_id);
                 if (count($filter_tags) > 0) {
                     $this->view->filter_tags = $filter_tags;
                     $show_view = true;
                 }
             }
         }
     }
     if (!$show_view) {
         $this->_helper->viewRenderer->setNoRender();
         $this->_helper->layout->disableLayout();
     }
 }
Example #3
0
?>
		<?php 
echo $form->listBox($product, 'categories', CHtml::listData(Yii::app()->db->createCommand("SELECT CONCAT(REPEAT('-----', level-2), name) AS name, id FROM product_category ORDER BY lft LIMIT 18446744073709551615 OFFSET 1")->query(), 'id', 'name'), array("multiple" => "multiple", 'style' => 'height: 300px;'));
?>
		<?php 
echo $form->error($product, 'categories');
?>
	</div>
	<p class="note">Utilisez la touche "CTRL" pour sélection multiple.</p>
	
	<div class="row">
		<?php 
echo $form->labelEx($product, 'tags');
?>
		<?php 
echo $form->listBox($product, 'tags', CHtml::listData(ProductTag::model()->findAll(), 'id', 'name'), array("multiple" => "multiple", 'style' => 'height: 150px;'));
?>
		<?php 
echo $form->error($product, 'tags');
?>
	</div>
	<p class="note">Utilisez la touche "CTRL" pour sélection multiple.</p>

	<div class="row">
		<?php 
echo $form->labelEx($product, 'price_regular');
?>
		<?php 
echo $form->textField($product, 'price_regular', array('style' => 'width: 60%;'));
?>
		<?php 
Example #4
0
/**
 * Get a list of product objects for the given tag
 *
 * @api
 * @since 1.2
 *
 * @param int|string $tag (required) The product tag name/id
 * @param array $options loading options
 * @return array Product objects
 **/
function shopp_tag_products($tag = false, $options = array())
{
    $defaults = array('limit' => 1000, 'debug' => false);
    $options = wp_parse_args($options, $defaults);
    if (!($term = term_exists($tag, ProductTag::$taxon))) {
        shopp_debug(__FUNCTION__ . " failed: {$tag} not a valid Shopp product tag.");
        return false;
    }
    $Tag = new ProductTag($term['term_id']);
    $Tag->load($options);
    return !empty($Tag->products) ? $Tag->products : array();
}
Example #5
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  *
  * @param integer $id
  *          the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel($id);
         if ($model->imageExists) {
             unlink($model->imagePath);
         }
         ProductTag::model()->deleteAll('product=:p', array(':p' => $model->id));
         $model->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }