当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::findAll方法代码示例

本文整理汇总了PHP中app\modules\shop\models\Product::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::findAll方法的具体用法?PHP Product::findAll怎么用?PHP Product::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\modules\shop\models\Product的用法示例。


在下文中一共展示了Product::findAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 * @var $form \yii\widgets\ActiveForm
 * @var $label string
 * @var $model \app\properties\AbstractModel
 * @var $multiple boolean
 * @var $property_id integer
 * @var $property_key string
 * @var $this \yii\web\View
 * @var $values \app\properties\PropertyValue
 */
use app\models\Property;
use app\modules\shop\models\Product;
use yii\helpers\ArrayHelper;
use kartik\helpers\Html;
$productIds = ArrayHelper::getColumn($values->values, 'value');
/** @var Product[] $products */
$products = Product::findAll($productIds);
?>

<dl>
    <?php 
if (count($productIds) == 0) {
    return;
}
$property = Property::findById($property_id);
echo Html::tag('dt', $property->name);
foreach ($products as $product) {
    echo Html::tag('dd', Html::a($product->name, ['@product', 'model' => $product]));
}
?>
</dl>
开发者ID:Jamshid90,项目名称:dotplant2,代码行数:30,代码来源:frontend-render.php

示例2: beforeDelete

 /**
  * Preparation to delete category.
  * Deleting related products and inserted categories.
  * @return bool
  */
 public function beforeDelete()
 {
     if (!parent::beforeDelete()) {
         return false;
     }
     $productObject = Object::getForClass(Product::className());
     switch ($this->deleteMode) {
         case self::DELETE_MODE_ALL:
             $products = !is_null($productObject) ? Product::find()->join('INNER JOIN', $productObject->categories_table_name . ' pc', 'pc.object_model_id = product.id')->where('pc.category_id = :id', [':id' => $this->id])->all() : [];
             break;
         case self::DELETE_MODE_MAIN_CATEGORY:
             $products = Product::findAll(['main_category_id' => $this->id]);
             break;
         default:
             $products = !is_null($productObject) ? Product::find()->join('INNER JOIN', $productObject->categories_table_name . ' pc', 'pc.object_model_id = product.id')->join('INNER JOIN', $productObject->categories_table_name . ' pc2', 'pc2.object_model_id = product.id')->where('pc.category_id = :id', [':id' => $this->id])->groupBy('pc2.object_model_id')->having('COUNT(*) = 1')->all() : [];
             break;
     }
     foreach ($products as $product) {
         $product->delete();
     }
     foreach ($this->children as $child) {
         $child->deleteMode = $this->deleteMode;
         $child->delete();
     }
     if (!is_null($productObject)) {
         Yii::$app->db->createCommand()->delete($productObject->categories_table_name, ['category_id' => $this->id])->execute();
     }
     return true;
 }
开发者ID:Razzwan,项目名称:dotplant2,代码行数:34,代码来源:Category.php

示例3:

<?php

/**
 * @var $attribute_name string
 * @var $form \yii\widgets\ActiveForm
 * @var $label string
 * @var $model \app\properties\AbstractModel
 * @var $multiple boolean
 * @var $property_id integer
 * @var $property_key string
 * @var $this \yii\web\View
 * @var $values \app\properties\PropertyValue
 */
use app\modules\shop\models\Product;
use yii\helpers\ArrayHelper;
$productIds = ArrayHelper::getColumn($values->values, 'value');
$data = ArrayHelper::map(Product::findAll($productIds), 'id', 'name');
?>

<?php 
echo \app\backend\widgets\Select2Ajax::widget(['initialData' => $data, 'form' => $form, 'model' => $model, 'modelAttribute' => $property_key, 'multiple' => $multiple === 1, 'searchUrl' => '/shop/backend-product/ajax-related-product', 'additional' => ['placeholder' => Yii::t('app', 'Search')]]);
开发者ID:Jamshid90,项目名称:dotplant2,代码行数:21,代码来源:frontend-edit.php


注:本文中的app\modules\shop\models\Product::findAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。