code
stringlengths
15
9.96M
docstring
stringlengths
1
10.1k
func_name
stringlengths
1
124
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
6
186
url
stringlengths
50
236
license
stringclasses
4 values
public function initState($country = '') { $state = isset($this->_address['state']) ? $this->_address['state'] : ''; if (!$country) { $country = $this->_country; } $stateArr = Yii::$service->helper->country->getStateByContryCode($country, $state); if(empty($stateArr)){ $stateArr = ''; } $this->stateArr = $stateArr; //if (!$stateArr) { // $stateHtml = '<input id="state" name="billing[state]" value="'.$state.'" title="State" class="address_state input-text" style="" type="text">'; //} else { // $stateHtml = '<select id="address:state" class="address_state validate-select" title="State" name="billing[state]"> // <option value="">Please select region, state or province</option>' // .$stateHtml.'</select>'; //} //$this->_stateHtml = $stateHtml; }
初始化省市
initState
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/block/onepage/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/block/onepage/Index.php
BSD-3-Clause
public function ajaxChangecountry() { $country = Yii::$app->request->get('country'); $country = \Yii::$service->helper->htmlEncode($country); $state = $this->initState($country); $code = Yii::$service->helper->appserver->status_success; $data = [ 'stateArr' => $this->stateArr, ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }
当改变国家的时候,ajax获取省市信息.
ajaxChangecountry
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/block/onepage/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/block/onepage/Index.php
BSD-3-Clause
public function getProductOptions($product_one, $custom_option_sku) { $custom_option_info_arr = []; $custom_option = isset($product_one['custom_option']) ? $product_one['custom_option'] : ''; $custom_option_sku = $product_one['custom_option_sku']; if (isset($custom_option[$custom_option_sku]) && !empty($custom_option[$custom_option_sku])) { $custom_option_info = $custom_option[$custom_option_sku]; foreach ($custom_option_info as $attr=>$val) { if (!in_array($attr, ['qty', 'sku', 'price', 'image'])) { $attr = str_replace('_', ' ', $attr); $attr = ucfirst($attr); $custom_option_info_arr[$attr] = $val; } } } $spu_options = $product_one['spu_options']; if (is_array($spu_options) && !empty($spu_options)) { foreach ($spu_options as $label => $val) { $custom_option_info_arr[$label] = $val; } } return $custom_option_info_arr; }
将产品页面选择的颜色尺码等显示出来,包括custom option 和spu options部分的数据.
getProductOptions
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/block/onepage/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/block/onepage/Index.php
BSD-3-Clause
public function getShippings($custom_shipping_method = '') { $country = $this->_country; if (!$this->_state) { $region = '*'; } else { $region = $this->_state; } $cartProductInfo = Yii::$service->cart->quoteItem->getCartProductInfo(); $product_weight = $cartProductInfo['product_weight']; $product_volume_weight = $cartProductInfo['product_volume_weight']; $product_final_weight = max($product_weight, $product_volume_weight); $cartShippingMethod = $this->_cart_info['shipping_method']; // 当前的货运方式 $current_shipping_method = Yii::$service->shipping->getCurrentShippingMethod($custom_shipping_method, $cartShippingMethod, $country, $region, $product_final_weight); $this->_shipping_method = $current_shipping_method; // 得到所有,有效的shipping method $shippingArr = $this->getShippingArr($product_final_weight, $current_shipping_method, $country, $region); return $shippingArr; }
@param $current_shipping_method | String 当前选择的货运方式 @return Array,数据格式为: [ 'method'=> $method, 'label' => $label, 'name' => $name, 'cost' => $symbol.$currentCurrencyCost, 'check' => $check, 'shipping_i' => $shipping_i, ] 得到所有的,有效shipping method数组。
getShippings
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/block/onepage/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/block/onepage/Index.php
BSD-3-Clause
public function getPayment() { $paymentArr = Yii::$service->payment->getStandardPaymentArr(); $pArr = []; if (!$this->_payment_method) { if (isset($this->_cart_info['payment_method']) && !empty($this->_cart_info['payment_method'])) { $this->_payment_method = $this->_cart_info['payment_method']; } //echo $this->_payment_method; if (!$this->_payment_method) { $i = 0; foreach ($paymentArr as $k => $v) { $i++; if ($i == 1) { $this->_payment_method = $k; $v['checked'] = true; } $pArr[$k] = $v; } } else { $checked_payment = 0; foreach ($paymentArr as $k => $v) { if ($this->_payment_method == $k) { $v['checked'] = true; $checked_payment = 1; } $pArr[$k] = $v; } if (!$checked_payment) { foreach ($paymentArr as $k => $v) { $this->_payment_method = $k; $pArr[$k]['checked'] = true; break; } } //var_dump($paymentArr); } } return $pArr; }
@return 得到所有的支付方式 在获取的同时,判断$this->_payment_method 是否存在,不存在则取 第一个支付方式,作为$this->_payment_method的值。
getPayment
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/block/onepage/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/block/onepage/Index.php
BSD-3-Clause
public function ajaxUpdateOrderAndShipping() { $country = Yii::$app->request->get('country'); $shipping_method = Yii::$app->request->get('shipping_method'); $address_id = Yii::$app->request->get('address_id'); $state = Yii::$app->request->get('state'); $country = \Yii::$service->helper->htmlEncode($country); $shipping_method = \Yii::$service->helper->htmlEncode($shipping_method); $address_id = \Yii::$service->helper->htmlEncode($address_id); $state = \Yii::$service->helper->htmlEncode($state); if ($address_id) { $this->_address_id = $address_id; $addressModel = Yii::$service->customer->address->getByPrimaryKey($this->_address_id); if ($addressModel['country']) { $country = $addressModel['country']; $this->_country = $addressModel['country']; } if ($addressModel['state']) { $state = $addressModel['state']; $this->_state = $addressModel['state']; } } elseif ($country) { $this->_country = $country; if (!$state) { $state = '*'; } $this->_state = $state; } if ($this->_country && $this->_state) { $shippings = $this->getShippings($shipping_method); $quoteItem = Yii::$service->cart->quoteItem->getCartProductInfo(); $product_weight = $quoteItem['product_weight']; // 计算运费。 $avaiable_method = Yii::$service->shipping->getAvailableShippingMethods($country,$region,$product_weight); $shippingInfo = $avaiable_method[$shipping_method]; $shippingCost = Yii::$service->shipping->getShippingCost($shipping_method, $shippingInfo, $product_weight, $country, $state); Yii::$service->cart->quote->setShippingCost($shippingCost); $last_cart_info = $this->getCartInfo(true, $shipping_method, $this->_country, $this->_state); $code = Yii::$service->helper->appserver->status_success; $data = [ 'cart_info' => $last_cart_info, 'shippings' => $shippings, ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } else { $code = Yii::$service->helper->appserver->order_shipping_country_empty; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } }
js函数 ajaxreflush() 执行后,就会执行这个函数 在 1.切换address list, 2.取消coupon, 3.切换国家和省市信息, 4.更改货运方式等 集中情况下,就会触发执行当前函数, 该函数会根据传递的参数,重新计算shipping 和order 部分信息,返回 给前端。 @proeprty Array, @return json_encode(Array),Array格式如下: [ 'status' => 'success', 'shippingHtml' => $shippingHtml, 'reviewOrderHtml' => $reviewOrderHtml, ] 返回给js后,js根据数据将信息更新到相应的部分。
ajaxUpdateOrderAndShipping
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/block/onepage/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/block/onepage/Index.php
BSD-3-Clause
public function actionVerifyinfo() { $orderIncrementId = Yii::$app->request->post('orderId'); if (!$orderIncrementId) { $data = []; $code = Yii::$service->helper->appserver->status_invalid_param; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } Yii::$service->order->setCurrentOrderIncrementId($orderIncrementId); $info = Yii::$service->payment->wxpayMicro->getScanCodeStart(); $code = Yii::$service->helper->appserver->status_success; $data = $info; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }
得到customer address
actionVerifyinfo
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/WxController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/WxController.php
BSD-3-Clause
public function getProductOptions($product_one) { $custom_option_info_arr = []; $custom_option = isset($product_one['custom_option']) ? $product_one['custom_option'] : ''; $custom_option_sku = $product_one['custom_option_sku']; if (isset($custom_option[$custom_option_sku]) && !empty($custom_option[$custom_option_sku])) { $custom_option_info = $custom_option[$custom_option_sku]; foreach ($custom_option_info as $attr=>$val) { if (!in_array($attr, ['qty', 'sku', 'price', 'image'])) { $attr = str_replace('_', ' ', $attr); $attr = ucfirst($attr); $custom_option_info_arr[$attr] = $val; } } } $spu_options = $product_one['spu_options']; if (is_array($spu_options) && !empty($spu_options)) { foreach ($spu_options as $label => $val) { $custom_option_info_arr[$label] = $val; } } return $custom_option_info_arr; }
将产品页面选择的颜色尺码等显示出来,包括custom option 和spu options部分的数据.
getProductOptions
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/CartController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/CartController.php
BSD-3-Clause
public function actionAdd() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } //echo 1;exit; $custom_option = Yii::$app->request->post('custom_option'); $product_id = Yii::$app->request->post('product_id'); $qty = Yii::$app->request->post('qty'); $buy_now = Yii::$app->request->post('buy_now'); //$custom_option = \Yii::$service->helper->htmlEncode($custom_option); $product_id = \Yii::$service->helper->htmlEncode($product_id); $qty = \Yii::$service->helper->htmlEncode($qty); $qty = abs(ceil((int) $qty)); $return = []; $code = 400; if ($qty && $product_id) { if ($custom_option) { $custom_option_sku = json_decode($custom_option, true); } if (empty($custom_option_sku)) { $custom_option_sku = null; } $item = [ 'product_id' => $product_id, 'qty' => $qty, 'custom_option_sku' => $custom_option_sku, ]; $innerTransaction = Yii::$app->db->beginTransaction(); try { if ($buy_now == 1) { // 如果是立即购买,则先将购物车中的产品disable掉 if (!Yii::$service->cart->selectAllItem(false)) { $innerTransaction->rollBack(); $code = Yii::$service->helper->appserver->cart_product_select_fail; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); } } $addToCart = Yii::$service->cart->addProductToCart($item); if ($addToCart) { $innerTransaction->commit(); $code = Yii::$service->helper->appserver->status_success; $data = [ 'items_count' => Yii::$service->cart->quote->getCartItemCount(), ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } else { $innerTransaction->rollBack(); $code = Yii::$service->helper->appserver->cart_product_add_fail; $data = Yii::$service->helper->errors->get(','); $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } } catch (\Exception $e) { $innerTransaction->rollBack(); } } else { $code = Yii::$service->helper->appserver->cart_product_add_param_invaild; $data = ''; $message = 'request post param: \'product_id\' and \'qty\' can not empty'; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data,$message); return $responseData; } }
把产品加入到购物车.
actionAdd
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/CartController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/CartController.php
BSD-3-Clause
public function actionAddcoupon() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } if (Yii::$app->user->isGuest) { $code = Yii::$service->helper->appserver->account_no_login_or_login_token_timeout; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } $coupon_code = trim(Yii::$app->request->post('coupon_code')); $coupon_code = \Yii::$service->helper->htmlEncode($coupon_code); if ($coupon_code) { $innerTransaction = Yii::$app->db->beginTransaction(); try { if (Yii::$service->cart->coupon->addCoupon($coupon_code)) { $innerTransaction->commit(); } else { $innerTransaction->rollBack(); } } catch (\Exception $e) { $innerTransaction->rollBack(); } $error_arr = Yii::$service->helper->errors->get(true); if (!empty($error_arr)) { if(is_array($error_arr)){ $error_str = implode(',', $error_arr); }else{ $error_str = $error_arr; } $code = Yii::$service->helper->appserver->cart_coupon_invalid; $data = [ 'error' => $error_str, ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } else { $code = Yii::$service->helper->appserver->status_success; $data = []; $message = 'add coupon success'; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data, $message); return $responseData; } } else { $code = Yii::$service->helper->appserver->cart_coupon_invalid; $data = [ 'error' => 'coupon code is empty', ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } }
购物车中添加优惠券.
actionAddcoupon
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/CartController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/CartController.php
BSD-3-Clause
public function actionCancelcoupon() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } if (Yii::$app->user->isGuest) { $code = Yii::$service->helper->appserver->account_no_login_or_login_token_timeout; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } $coupon_code = trim(Yii::$app->request->post('coupon_code')); if ($coupon_code) { $innerTransaction = Yii::$app->db->beginTransaction(); try { $cancelStatus = Yii::$service->cart->coupon->cancelCoupon($coupon_code); if (!$cancelStatus) { $innerTransaction->rollBack(); $code = Yii::$service->helper->appserver->cart_coupon_invalid; $data = [ 'error' => 'cancel coupon code fail', ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } $error_arr = Yii::$service->helper->errors->get(true); if (!empty($error_arr)) { if (is_array($error_arr)) { $error_str = implode(',', $error_arr); } else { $error_str = $error_arr; } $innerTransaction->rollBack(); $code = Yii::$service->helper->appserver->cart_coupon_invalid; $data = [ 'error' => $error_str, ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } else { $innerTransaction->commit(); $code = Yii::$service->helper->appserver->status_success; $data = []; $message = 'cancel coupon success'; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data, $message); return $responseData; } } catch (\Exception $e) { $innerTransaction->rollBack(); $code = Yii::$service->helper->appserver->cart_coupon_invalid; $data = [ 'error' => 'cancel coupon fail', ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } } else { $code = Yii::$service->helper->appserver->cart_coupon_invalid; $data = [ 'error' => 'coupon code is empty', ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } }
购物车中取消优惠券.
actionCancelcoupon
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/CartController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/CartController.php
BSD-3-Clause
public function actionIndex() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } $guestOrder = Yii::$app->store->get('order', 'guestOrder'); if($guestOrder != Yii::$app->store->enable && Yii::$app->user->isGuest){ $code = Yii::$service->helper->appserver->account_no_login_or_login_token_timeout; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } return $this->getBlock()->getLastData(); }
public function init(){ Yii::$service->page->theme->layoutFile = 'one_step_checkout.php'; }
actionIndex
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/OnepageController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/OnepageController.php
BSD-3-Clause
public function actionGetaddresslist() { //$identity = Yii::$app->user->identity; $addressList = Yii::$service->customer->address->currentAddressList(); $code = Yii::$service->helper->appserver->status_success; $data = [ 'addressList' => $addressList, ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }
得到customer address
actionGetaddresslist
php
fecshop/yii2_fecshop
app/appserver/modules/Checkout/controllers/OnepageController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Checkout/controllers/OnepageController.php
BSD-3-Clause
protected function getFilterAttr() { if (!$this->_filter_attr) { $this->_filter_attr = $filterAttr = Yii::$service->search->filterAttr; } return $this->_filter_attr; }
得到侧栏属性过滤属性
getFilterAttr
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function getRefineByInfo() { $refineInfo = []; $chosenAttrs = Yii::$app->request->get('filterAttrs'); $chosenAttrArr = json_decode($chosenAttrs,true); if(!empty($chosenAttrArr)){ foreach ($chosenAttrArr as $attr=>$val) { $refineInfo[] = [ 'attr' => $attr, 'val' => $val, ]; } } $currenctPriceFilter = Yii::$app->request->get($this->_filterPrice); if($currenctPriceFilter){ $refineInfo[] = [ 'attr' => $this->_filterPrice, 'val' => $currenctPriceFilter, ]; } if (!empty($refineInfo)) { $arr[] = [ 'attr' => 'clearAll', 'val' => 'clear all', ]; $refineInfo = array_merge($arr, $refineInfo); } return $refineInfo; }
得到已经选择了的过滤属性,譬如对color属性,点击了blue,进行了选择,就会出现在这里 方便用户通过点击的方式取消掉属性过滤
getRefineByInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function getFilterInfo() { $filter_info = []; $filter_attrs = $this->getFilterAttr(); $chosenAttrs = Yii::$app->request->get('filterAttrs'); $chosenAttrArr = json_decode($chosenAttrs,true); foreach ($filter_attrs as $attr) { if ($attr != 'price') { $label = preg_replace_callback('/([-_]+([a-z]{1}))/i',function($matches){ return ' '.strtoupper($matches[2]); },$attr); $items = Yii::$service->search->getFrontSearchFilter($attr, $this->_where); if(is_array($items) && !empty($items)){ foreach($items as $k=>$one){ if(isset($chosenAttrArr[$attr]) && $chosenAttrArr[$attr] == $one['_id']){ $items[$k]['selected'] = true; } else { $items[$k]['selected'] = false; } } } $filter_info[$attr] = [ 'label' => $label, 'items' => $items, ]; } } return $filter_info; }
得到搜索页面进行过滤的属性
getFilterInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function getFormatFilterPrice($price_item) { list($f_price, $l_price) = explode('-', $price_item); $str = ''; if ($f_price == '0' || $f_price) { $f_price = Yii::$service->product->price->formatPrice($f_price); $str .= $f_price['symbol'].$f_price['value'].'---'; } if ($l_price) { $l_price = Yii::$service->product->price->formatPrice($l_price); $str .= $l_price['symbol'].$l_price['value']; } return $str; }
产品价格显示格式处理
getFormatFilterPrice
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function getNumPerPage() { if (!$this->_numPerPageVal) { $numPerPage = Yii::$app->request->get($this->_numPerPage); $category_query_config = Yii::$app->controller->module->params['search_query']; if (!$numPerPage) { if (isset($category_query_config['numPerPage'])) { if (is_array($category_query_config['numPerPage'])) { $this->_numPerPageVal = $category_query_config['numPerPage'][0]; } } } elseif (!$this->_numPerPageVal) { if (isset($category_query_config['numPerPage']) && is_array($category_query_config['numPerPage'])) { $numPerPageArr = $category_query_config['numPerPage']; if (in_array((int) $numPerPage, $numPerPageArr)) { $this->_numPerPageVal = $numPerPage; } else { throw new InvalidValueException('Incorrect numPerPage value:'.$numPerPage); } } } } return $this->_numPerPageVal; }
得到每页显示的产品的个数。
getNumPerPage
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function getPageNum() { $numPerPage = Yii::$app->request->get($this->_page); return $numPerPage ? (int) $numPerPage : 1; }
得到第几页
getPageNum
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function getSearchProductColl() { /////////////////************ $select = [ 'product_id','sku', 'spu', 'name', 'image', 'price', 'special_price', 'special_from', 'special_to', 'url_key', 'score', ]; $where = $this->_where; $search_text = Yii::$app->controller->module->params['search_query']; $pageNum = $this->getPageNum(); $numPerPage = $this->getNumPerPage(); $product_search_max_count = Yii::$app->controller->module->params['product_search_max_count']; $filterAttr = $this->getFilterAttr(); $productList = Yii::$service->search->getSearchProductColl($select, $where, $pageNum, $numPerPage, $product_search_max_count, $filterAttr); $i = 1; $product_return = []; $products = $productList['coll']; if(is_array($products) && !empty($products)){ foreach($products as $k=>$v){ if($v['sku']){ $i++; $products[$k]['url'] = '/catalog/product/'.$v['product_id']; $products[$k]['image'] = Yii::$service->product->image->getResize($v['image'],296,false); $priceInfo = Yii::$service->product->price->getCurrentCurrencyProductPriceInfo($v['price'], $v['special_price'],$v['special_from'],$v['special_to']); $products[$k]['price'] = isset($priceInfo['price']) ? $priceInfo['price'] : ''; $products[$k]['special_price'] = isset($priceInfo['special_price']) ? $priceInfo['special_price'] : ''; if (isset($products[$k]['special_price']['value'])) { $products[$k]['special_price']['value'] = Yii::$service->helper->format->numberFormat($products[$k]['special_price']['value']); } if (isset($products[$k]['price']['value'])) { $products[$k]['price']['value'] = Yii::$service->helper->format->numberFormat($products[$k]['price']['value']); } if($i%2 === 0){ $arr = $products[$k]; }else{ $product_return[] = [ 'one' => $arr, 'two' => $products[$k], ]; } } } if($i%2 === 0){ $product_return[] = [ 'one' => $arr, 'two' => [], ]; } } $productList['coll'] = $product_return; return $productList; }
得到搜索的产品collection
getSearchProductColl
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
protected function initSearch() { //$primaryKey = Yii::$service->category->getPrimaryKey(); //$primaryVal = Yii::$app->request->get($primaryKey); //$this->_primaryVal = $primaryVal; //$category = Yii::$service->category->getByPrimaryKey($primaryVal); //$this->_category = $category ; $searchText = Yii::$app->request->get('q'); $searchText = \Yii::$service->helper->htmlEncode($searchText); $this->_searchText = $searchText; $this->_where = $this->initWhere(); return true; }
初始化部分
initSearch
php
fecshop/yii2_fecshop
app/appserver/modules/Catalogsearch/controllers/IndexController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalogsearch/controllers/IndexController.php
BSD-3-Clause
public function actionLang() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } $langs = Yii::$service->store->serverLangs; $currentLangCode = Yii::$service->store->currentLangCode; return [ 'langList' => $langs, 'currentLang' => $currentLangCode ]; }
语言
actionLang
php
fecshop/yii2_fecshop
app/appserver/modules/General/controllers/BaseController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/General/controllers/BaseController.php
BSD-3-Clause
public function actionFirst() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } $code = Yii::$service->helper->appserver->status_success; $startConfig = Yii::$app->controller->module->params['startConfig']; $startImageUrl = Yii::$service->image->getImgUrl($startConfig['picUrl']); $data = [ [ 'businessId' => 115781, 'picUrl' => $startImageUrl, 'title' => Yii::$service->page->translate->__($startConfig['title']), // '', 'remark' => Yii::$service->page->translate->__($startConfig['remark']), ], ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }
general/start/first
actionFirst
php
fecshop/yii2_fecshop
app/appserver/modules/Wx/controllers/StartController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Wx/controllers/StartController.php
BSD-3-Clause
public function actionLogin() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } $code = Yii::$service->helper->appserver->status_success; $data = [ [ 'businessId' => 115781, 'dateAdd' => '2019-06-22 07:49:37', 'id' => 25407, 'paixu' => 0, 'picUrl' => "https://cdn.it120.cc/apifactory/2019/06/22/249199f1-6d15-4de2-9e90-94633586056c.jpg", 'status' => 0, 'statusStr' => '显示', 'title' => 'fecshop', 'type' => 'start', 'userId' => 16619, ], ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }
general/start/first
actionLogin
php
fecshop/yii2_fecshop
app/appserver/modules/Wx/controllers/AccountController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Wx/controllers/AccountController.php
BSD-3-Clause
public function getAddCaptcha() { if (!$this->_add_captcha) { $appName = Yii::$service->helper->getAppName(); $addCaptcha = Yii::$app->store->get($appName.'_catalog','review_add_captcha'); // $reviewParam = Yii::$app->getModule('catalog')->params['review']; $this->_add_captcha = ($addCaptcha == Yii::$app->store->enable) ? true : false; } return $this->_add_captcha; }
@return boolean , reviewҳǷ֤֤
getAddCaptcha
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/block/reviewproduct/Add.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/block/reviewproduct/Add.php
BSD-3-Clause
public function saveReview($editForm) { if(Yii::$service->product->review->addReview($editForm)){ $code = Yii::$service->helper->appserver->status_success; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }else{ $code = Yii::$service->helper->appserver->product_save_review_fail; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } }
@param $editForm | Array @return boolean Ϣ
saveReview
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/block/reviewproduct/Add.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/block/reviewproduct/Add.php
BSD-3-Clause
protected function getProductPriceInfo($product) { $price = $product['price']; $special_price = $product['special_price']; $special_from = $product['special_from']; $special_to = $product['special_to']; return Yii::$service->product->price->getCurrentCurrencyProductPriceInfo($price, $special_price, $special_from, $special_to); }
@param $product | String Or Object õƷļ۸Ϣ
getProductPriceInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/block/reviewproduct/Add.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/block/reviewproduct/Add.php
BSD-3-Clause
protected function getProductPage($countTotal) { if ($countTotal <= $this->numPerPage) { return ''; } $config = [ 'class' => 'fecshop\app\apphtml5\widgets\Page', 'view' => 'widgets/page.php', 'pageNum' => $this->pageNum, 'numPerPage' => $this->numPerPage, 'countTotal' => $countTotal, 'page' => $this->_page, ]; return Yii::$service->page->widget->renderContent('category_product_page', $config); }
@param $countTotal | Int 得到toolbar的分页部分
getProductPage
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/block/reviewproduct/Lists.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/block/reviewproduct/Lists.php
BSD-3-Clause
public function initParam() { $this->pageNum = Yii::$app->request->get($this->_page); $this->pageNum = $this->pageNum ? $this->pageNum : 1; //$this->spu = Yii::$app->request->get('spu'); $this->product_id = Yii::$app->request->get('product_id'); // $review = Yii::$app->getModule('catalog')->params['review']; $appName = Yii::$service->helper->getAppName(); $reviewPageReviewCount = Yii::$app->store->get($appName.'_catalog','review_reviewPageReviewCount'); //$productPageReviewCount = $reviewPageReviewCount ? $reviewPageReviewCount : 10; $this->numPerPage = $reviewPageReviewCount ? $reviewPageReviewCount : $this->numPerPage; }
初始化参数
initParam
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/block/reviewproduct/Lists.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/block/reviewproduct/Lists.php
BSD-3-Clause
protected function getProductPriceInfo($product) { $price = $product['price']; $special_price = $product['special_price']; $special_from = $product['special_from']; $special_to = $product['special_to']; return Yii::$service->product->price->getCurrentCurrencyProductPriceInfo($price, $special_price, $special_from, $special_to); }
产品价格信息
getProductPriceInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/block/reviewproduct/Lists.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/block/reviewproduct/Lists.php
BSD-3-Clause
public function filterProductImg($product_images){ $this->_image_thumbnails = $product_images; //$this->_image_detail['gallery'] = $product_images['gallery']; if(isset($product_images['gallery']) && is_array($product_images['gallery'])){ $thumbnails_arr = []; $detail_arr = []; foreach($product_images['gallery'] as $one){ $is_thumbnails = $one['is_thumbnails']; $is_detail = $one['is_detail']; if($is_thumbnails == 1){ $thumbnails_arr[] = $one; } if($is_detail == 1){ $detail_arr[] = Yii::$service->product->image->getUrl($one['image']); } } $this->_image_thumbnails['gallery'] = $thumbnails_arr; $this->_image_detail = $detail_arr; } if(isset($product_images['main']['is_detail']) && $product_images['main']['is_detail'] == 1 ){ $this->_image_detail[] = Yii::$service->product->image->getUrl($product_images['main']['image']); } }
@param $product_images | Array ,产品的图片属性 根据图片数组,得到橱窗图,和描述图 橱窗图:在产品详细页面顶部,放大镜显示部分的产品列表 描述图,在产品description文字描述后面显示的产品图片。
filterProductImg
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
protected function getSpuData($select) { $spu = $this->_product['spu']; return Yii::$service->product->spuCollData($select, $this->_productSpuAttrArr, $spu); }
@param $select | Array , 需要查询的字段。 得到当前spu下面的所有的sku的数组、 这个是为了产品详细页面的spu下面的产品切换,譬如同一spu下的不同的颜色尺码切换。
getSpuData
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu) { $current = $this->_currentSpuAttrValArr; $active = false; if (isset($this->_currentSpuAttrValArr[$spuAttr])) { if ($attrVal != $this->_currentSpuAttrValArr[$spuAttr]) { $current[$spuAttr] = $attrVal; } else { $active = true; } } $reverse_key = $this->generateSpuReverseKey($current); $return = []; $return['attr_val'] = $attrVal; $return['active'] = 'noactive'; if (isset($reverse_val_spu[$reverse_key]) && is_array($reverse_val_spu[$reverse_key])) { $return['active'] = 'active'; $arr = $reverse_val_spu[$reverse_key]; foreach ($arr as $k=>$v) { $return[$k] = $v; } if ($spuAttr == $this->_spuAttrShowAsImg) { $return['show_as_img'] = Yii::$service->product->image->getResize($arr['main_img'],[50,55],false); } } else if ($this->_spuAttrShowAsImg){ // 如果是图片,不存在,则使用备用的。 if ($spuAttr == $this->_spuAttrShowAsImg) { $return['active'] = 'active'; $arr = $this->_spuAttrShowAsImgArr[$attrVal]; if (is_array($arr) && !empty($arr)) { foreach ($arr as $k=>$v) { $return[$k] = $v; } } $return['show_as_img'] = Yii::$service->product->image->getResize($arr['main_img'],[50,55],false); } } else if ($this->_spuAttrShowAsTop){ if ($spuAttr == $this->_spuAttrShowAsTop) { $return['active'] = 'active'; $arr = $this->_spuAttrShowAsTopArr[$attrVal]; if (is_array($arr) && !empty($arr)) { foreach ($arr as $k=>$v) { $return[$k] = $v; } } } } if ($active) { $return['active'] = 'current'; } $productPrimaryKey = Yii::$service->product->getPrimaryKey(); $return['_id'] = (string)$return[$productPrimaryKey]; return $return; }
spu属性部分
getSpuAttrInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
protected function sortSpuAttr($spuAttr, $data) { // 对size排序一下 $size = []; $attr_group = $this->_product['attr_group']; $attrInfo = Yii::$service->product->getGroupAttrInfo($attr_group); $size_arr = isset($attrInfo[$spuAttr]['display']['data']) ? $attrInfo[$spuAttr]['display']['data'] : ''; $d_arr = []; if (is_array($size_arr) && !empty($size_arr)) { foreach ($size_arr as $size) { if (isset($data[$size])) { $d_arr[$size] = $data[$size]; } } if (!empty($d_arr)) { // 不在里面的规格属性(新建产品添加的规格属性),添加进去 foreach ($data as $size=>$d) { if (!isset($d_arr[$size])) { $d_arr[$size] = $data[$size]; } } return $d_arr; } } return $data; }
@param $data | Array 各个尺码对应的产品数组 @return array 排序后的数组 该函数,按照在配置中的size的顺序,将$data中的数据进行排序,让其按照尺码的由小到大的顺序 排列,譬如 :s,m,l,xl,xxl,xxxl等
sortSpuAttr
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
protected function getProductPriceInfo() { $price = $this->_product['price']; $special_price = $this->_product['special_price']; $special_from = $this->_product['special_from']; $special_to = $this->_product['special_to']; return Yii::$service->product->price->getCurrentCurrencyProductPriceInfo($price, $special_price, $special_from, $special_to); }
@return array 得到当前货币状态下的产品的价格和特价信息。
getProductPriceInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
protected function initProduct() { //$primaryKey = Yii::$service->product->getPrimaryKey(); $primaryVal = Yii::$app->request->get('product_id'); $this->_primaryVal = $primaryVal; $product = Yii::$service->product->getByPrimaryKey($primaryVal); if ($product) { $enableStatus = Yii::$service->product->getEnableStatus(); if ($product['status'] != $enableStatus){ return false; } } else { return false; } $this->_product = $product; Yii::$app->view->registerMetaTag([ 'name' => 'keywords', 'content' => Yii::$service->store->getStoreAttrVal($product['meta_keywords'], 'meta_keywords'), ]); Yii::$app->view->registerMetaTag([ 'name' => 'description', 'content' => Yii::$service->store->getStoreAttrVal($product['meta_description'], 'meta_description'), ]); $this->_title = Yii::$service->store->getStoreAttrVal($product['meta_title'], 'meta_title'); $name = Yii::$service->store->getStoreAttrVal($product['name'], 'name'); //$this->breadcrumbs($name); $this->_title = $this->_title ? $this->_title : $name; Yii::$app->view->title = $this->_title; //$this->_where = $this->initWhere(); // 通过上面查询的属性组,得到属性组对应的属性列表 // 然后重新查询产品 $attr_group = $this->_product['attr_group']; Yii::$service->product->addGroupAttrs($attr_group); // 重新查询产品信息。 $product = Yii::$service->product->getByPrimaryKey($primaryVal); $this->_product = $product; return true; }
初始化数据包括 主键值:$this->_primaryVal 当前产品对象:$this->_product Meta keywords , Meta Description等信息的设置。 Title的设置。 根据当前产品的attr_group(属性组信息)重新给Product Model增加相应的属性组信息 然后,重新获取当前产品对象:$this->_product,此时加入了配置中属性组对应的属性。
initProduct
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
public function actionGetcoprice() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } $custom_option_sku = Yii::$app->request->get('custom_option_sku'); $product_id = Yii::$app->request->get('product_id'); $qty = Yii::$app->request->get('qty'); $cart_price = 0; $custom_option_price = 0; $product = Yii::$service->product->getByPrimaryKey($product_id); $cart_price = Yii::$service->product->price->getCartPriceByProductId($product_id, $qty, $custom_option_sku); if (!$cart_price) { return; } $price_info = [ 'price' => $cart_price, ]; $priceView = [ 'view' => 'catalog/product/index/price.php', ]; $priceParam = [ 'price_info' => $price_info, ]; echo json_encode([ 'price' =>Yii::$service->page->widget->render($priceView, $priceParam), ]); exit; }
ajax 得到产品加入购物车的价格。
actionGetcoprice
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ProductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ProductController.php
BSD-3-Clause
public function actionAdd() { if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } //$reviewParam = Yii::$app->getModule('catalog')->params['review']; $appName = Yii::$service->helper->getAppName(); $addReviewOnlyLogin = Yii::$app->store->get($appName.'_catalog','review_addReviewOnlyLogin'); //$addReviewOnlyLogin = ($addReviewOnlyLogin == Yii::$app->store->enable) ? true : false; if ($addReviewOnlyLogin == Yii::$app->store->enable && Yii::$app->user->isGuest) { $identity = Yii::$service->customer->loginByAccessToken(get_class($this)); if(!$identity){ $code = Yii::$service->helper->appserver->account_no_login_or_login_token_timeout; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } } return $this->getBlock()->getLastData(); }
增加评论
actionAdd
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/ReviewproductController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/ReviewproductController.php
BSD-3-Clause
public function actionWxindex(){ if(Yii::$app->request->getMethod() === 'OPTIONS'){ return []; } // 每页显示的产品个数,进行安全验证,如果个数不在预先设置的值内,则会报错。 // 这样是为了防止恶意攻击,也就是发送很多不同的页面个数的链接,绕开缓存。 $this->getNumPerPage(); //echo Yii::$service->page->translate->__('fecshop,{username}', ['username' => 'terry']); if(!$this->initCategory()){ $code = Yii::$service->helper->appserver->category_not_exist; $data = []; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; } // change current layout File. //Yii::$service->page->theme->layoutFile = 'home.php'; $productCollInfo = $this->getWxCategoryProductColl(); $products = $productCollInfo['coll']; $this->_productCount = $productCollInfo['count']; $p = Yii::$app->request->get('p'); $p = (int)$p; $query_item = $this->getQueryItem(); $page_count = $this->getProductPageCount(); $this->category_name = Yii::$service->store->getStoreAttrVal($this->_category['name'], 'name'); $code = Yii::$service->helper->appserver->status_success; $data = [ 'name' => $this->category_name , 'name_default_lang' => Yii::$service->fecshoplang->getDefaultLangAttrVal($this->_category['name'], 'name'), 'title' => $this->_title, 'image' => $this->_category['image'] ? Yii::$service->category->image->getUrl($this->_category['image']) : '', 'products' => $products, 'query_item' => $query_item, 'refine_by_info' => $this->getRefineByInfo(), 'filter_info' => $this->getFilterInfo(), 'filter_price' => $this->getFilterPrice(), 'filter_category' => $this->getFilterCategory(), 'page_count' => $page_count, ]; $responseData = Yii::$service->helper->appserver->getResponseData($code, $data); return $responseData; }
微信分类部分数据
actionWxindex
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getFilterCategory() { $arr = []; if (!Yii::$service->category->isEnableFilterSubCategory()) { return $arr; } $category_id = $this->_primaryVal; $parent_id = $this->_category['parent_id']; $filter_category = Yii::$service->category->getFilterCategory($category_id, $parent_id); return $this->getAppServerFilterCategory($filter_category); }
得到子分类,如果子分类不存在,则返回同级分类。
getFilterCategory
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getProductPageCount() { $productNumPerPage = $this->getNumPerPage(); $productCount = $this->_productCount; $pageNum = $this->getPageNum(); return $this->_page_count = ceil($productCount / $productNumPerPage); }
得到产品页面的toolbar部分 也就是分类页面的分页工具条部分。
getProductPageCount
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getFilterAttr() { return Yii::$service->category->getFilterAttr($this->_category); }
@return Array 得到当前分类,侧栏用于过滤的属性数组,由三部分计算得出 1.全局默认属性过滤(catalog module 配置文件中配置 category_filter_attr), 2.当前分类属性过滤,也就是分类表的 filter_product_attr_selected 字段 3.当前分类去除的属性过滤,也就是分类表的 filter_product_attr_unselected 最终出来一个当前分类,用于过滤的属性数组。
getFilterAttr
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getFilterInfo() { $chosenAttrs = Yii::$app->request->get('filterAttrs'); return Yii::$service->category->getFilterInfo($this->_category, $this->_where, $chosenAttrs); /* $filter_info = []; $filter_attrs = $this->getFilterAttr(); $chosenAttrs = Yii::$app->request->get('filterAttrs'); $chosenAttrArr = json_decode($chosenAttrs,true); foreach ($filter_attrs as $attr) { if ($attr != 'price') { $label = preg_replace_callback('/([-_]+([a-z]{1}))/i',function($matches){ return ' '.strtoupper($matches[2]); },$attr); $items = Yii::$service->product->getFrontCategoryFilter($attr, $this->_where); if(is_array($items) && !empty($items)){ foreach($items as $k=>$one){ if(isset($chosenAttrArr[$attr]) && $chosenAttrArr[$attr] == $one['_id']){ $items[$k]['selected'] = true; } else { $items[$k]['selected'] = false; } if (isset($items[$k]['_id'])) { $items[$k]['label'] = Yii::$service->page->translate->__($items[$k]['_id']); } } } $label = Yii::$service->page->translate->__($label); $filter_info[$attr] = [ 'label' => $label, 'items' => $items, ]; } } return $filter_info; */ }
侧栏除价格外的其他属性过滤部分
getFilterInfo
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getFormatFilterPrice($price_item) { list($f_price, $l_price) = explode('-', $price_item); $str = ''; if ($f_price == '0' || $f_price) { $f_price = Yii::$service->product->price->formatPrice($f_price); $str .= $f_price['symbol'].$f_price['value'].'---'; } if ($l_price) { $l_price = Yii::$service->product->price->formatPrice($l_price); $str .= $l_price['symbol'].$l_price['value']; } return $str; }
格式化价格格式,侧栏价格过滤部分
getFormatFilterPrice
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getOrderBy() { $primaryKey = Yii::$service->category->getPrimaryKey(); $sort = Yii::$app->request->get($this->_sort); $direction = Yii::$app->request->get($this->_direction); //$category_query_config = Yii::$app->controller->module->params['category_query']; $sortConfig = $this->_sort_items; if (is_array($sortConfig)) { //return $category_query_config['numPerPage'][0]; if ($sort && isset($sortConfig[$sort])) { $orderInfo = $sortConfig[$sort]; //var_dump($orderInfo); if (!$direction) { $direction = $orderInfo['direction']; } } else { foreach ($sortConfig as $k => $v) { $orderInfo = $v; if (!$direction) { $direction = $v['direction']; } break; } } $db_columns = $orderInfo['db_columns']; $storageName = Yii::$service->product->serviceStorageName(); if ($direction == 'desc') { $direction = $storageName == 'mongodb' ? -1 : SORT_DESC; } else { $direction = $storageName == 'mongodb' ? 1 :SORT_ASC; } //var_dump([$db_columns => $direction]); //exit; return [$db_columns => $direction]; } }
用于搜索条件的排序部分
getOrderBy
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getNumPerPage() { if (!$this->_numPerPageVal) { $numPerPage = Yii::$app->request->get($this->_numPerPage); //$category_query_config = Yii::$app->getModule('catalog')->params['category_query']; $appName = Yii::$service->helper->getAppName(); $categoryConfigNumPerPage = Yii::$app->store->get($appName.'_catalog','category_query_numPerPage'); $category_query_config['numPerPage'] = explode(',',$categoryConfigNumPerPage); if (!$numPerPage) { if (isset($category_query_config['numPerPage'])) { if (is_array($category_query_config['numPerPage'])) { $this->_numPerPageVal = $category_query_config['numPerPage'][0]; } } } elseif (!$this->_numPerPageVal) { if (isset($category_query_config['numPerPage']) && is_array($category_query_config['numPerPage'])) { $numPerPageArr = $category_query_config['numPerPage']; if (in_array((int) $numPerPage, $numPerPageArr)) { $this->_numPerPageVal = $numPerPage; } else { throw new InvalidValueException('Incorrect numPerPage value:'.$numPerPage); } } } } return $this->_numPerPageVal; }
分类页面的产品,每页显示的产品个数。 对于前端传递的个数参数,在后台验证一下是否是合法的个数(配置里面有一个分类产品个数列表) 如果不合法,则报异常 这个功能是为了防止分页攻击,伪造大量的不同个数的url,绕过缓存。
getNumPerPage
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function getPageNum() { $numPerPage = Yii::$app->request->get($this->_page); return $numPerPage ? (int) $numPerPage : 1; }
得到当前第几页
getPageNum
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function initWhere() { $chosenAttrs = Yii::$app->request->get('filterAttrs'); $chosenAttrArr = json_decode($chosenAttrs,true); //var_dump($chosenAttrArr); if(is_array($chosenAttrArr) && !empty($chosenAttrArr)){ $filterAttr = $this->getFilterAttr(); //var_dump($filterAttr); foreach ($filterAttr as $attr) { if(isset($chosenAttrArr[$attr]) && $chosenAttrArr[$attr]){ $where[$attr] = $chosenAttrArr[$attr]; } } } $filter_price = Yii::$app->request->get('filterPrice'); //echo $filter_price; list($f_price, $l_price) = explode('-', $filter_price); if ($f_price == '0' || $f_price) { $where[$this->_filterPriceAttr]['$gte'] = (float) $f_price; } if ($l_price) { $where[$this->_filterPriceAttr]['$lte'] = (float) $l_price; } $where['category'] = $this->_primaryVal; //var_dump($where); return $where; }
得到用于查询的where数组。
initWhere
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
protected function initCategory() { //$primaryKey = 'category_id'; $primaryVal = Yii::$app->request->get('categoryId'); $this->_primaryVal = $primaryVal; $category = Yii::$service->category->getByPrimaryKey($primaryVal); if ($category) { $enableStatus = Yii::$service->category->getCategoryEnableStatus(); if ($category['status'] != $enableStatus){ return false; } } else { return false; } $this->_category = $category; $this->_where = $this->initWhere(); return true; }
分类部分的初始化 对一些属性进行赋值。
initCategory
php
fecshop/yii2_fecshop
app/appserver/modules/Catalog/controllers/CategoryController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/Catalog/controllers/CategoryController.php
BSD-3-Clause
public function getBlock($blockName = '') { if (!$blockName) { $blockName = $this->action->id; } if (!$this->blockNamespace) { $this->blockNamespace = Yii::$app->controller->module->blockNamespace; } if (!$this->blockNamespace) { throw new \yii\web\HttpException(406, 'blockNamespace is empty , you should config it in module->blockNamespace or controller blockNamespace '); } $relativeFile = '\\'.$this->blockNamespace; $relativeFile .= '\\'.$this->id.'\\'.ucfirst($blockName); //查找是否在rewriteMap中存在重写 $relativeFile = Yii::mapGetName($relativeFile); return new $relativeFile(); }
get current block you can change $this->blockNamespace.
getBlock
php
fecshop/yii2_fecshop
app/console/modules/ConsoleController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/ConsoleController.php
BSD-3-Clause
public function actionSynccount() { $count = Yii::$service->category->collCount(); echo $count ; }
得到个数
actionSynccount
php
fecshop/yii2_fecshop
app/console/modules/Category/controllers/MysqldatatomongoController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Category/controllers/MysqldatatomongoController.php
BSD-3-Clause
public function actionSyncpagenum() { $count = Yii::$service->category->collCount(); echo ceil($count / $this->numPerPage); }
得到个数
actionSyncpagenum
php
fecshop/yii2_fecshop
app/console/modules/Category/controllers/MysqldatatomongoController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Category/controllers/MysqldatatomongoController.php
BSD-3-Clause
public function actionSynccount() { $count = Yii::$service->category->collCount(); echo $count ; }
得到个数
actionSynccount
php
fecshop/yii2_fecshop
app/console/modules/Category/controllers/MongodatatomysqlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Category/controllers/MongodatatomysqlController.php
BSD-3-Clause
public function actionSyncpagenum() { $count = Yii::$service->category->collCount(); echo ceil($count / $this->numPerPage); }
得到个数
actionSyncpagenum
php
fecshop/yii2_fecshop
app/console/modules/Category/controllers/MongodatatomysqlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Category/controllers/MongodatatomysqlController.php
BSD-3-Clause
public function actionNowtime() { echo time(); }
得到当前的时间。
actionNowtime
php
fecshop/yii2_fecshop
app/console/modules/Helper/controllers/UrlrewriteController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Helper/controllers/UrlrewriteController.php
BSD-3-Clause
public function actionProductpagenum() { $count = Yii::$service->product->collCount($filter); echo ceil($count / $this->_numPerPage); }
得到产品的页数。
actionProductpagenum
php
fecshop/yii2_fecshop
app/console/modules/Helper/controllers/UrlrewriteController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Helper/controllers/UrlrewriteController.php
BSD-3-Clause
public function actionProductcount() { $count = Yii::$service->product->collCount($filter); echo $count; }
得到产品的总数。
actionProductcount
php
fecshop/yii2_fecshop
app/console/modules/Helper/controllers/UrlrewriteController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Helper/controllers/UrlrewriteController.php
BSD-3-Clause
public function actionCategorypagenum() { $count = Yii::$service->category->collCount($filter); echo ceil($count / $this->_numPerPage); }
得到分类的页数。
actionCategorypagenum
php
fecshop/yii2_fecshop
app/console/modules/Helper/controllers/UrlrewriteController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Helper/controllers/UrlrewriteController.php
BSD-3-Clause
public function actionCategorycount() { $count = Yii::$service->category->collCount($filter); echo $count; }
得到分类的总数。
actionCategorycount
php
fecshop/yii2_fecshop
app/console/modules/Helper/controllers/UrlrewriteController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Helper/controllers/UrlrewriteController.php
BSD-3-Clause
public function actionClearnoactive($nowtime) { echo 'delete date gt '.$nowtime."\n"; Yii::$service->url->rewrite->removeByUpdatedAt($nowtime); }
删除时间小于nowtime的.
actionClearnoactive
php
fecshop/yii2_fecshop
app/console/modules/Helper/controllers/UrlrewriteController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Helper/controllers/UrlrewriteController.php
BSD-3-Clause
protected function handleMessage($id, $message) { // $message = unserialize($message); var_dump($message); // do some thing ... // \Yii::info($message,'fecshop_debug'); return true; }
дú
handleMessage
php
fecshop/yii2_fecshop
app/console/modules/Amqp/block/Queue.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Amqp/block/Queue.php
BSD-3-Clause
public function actionTest() { // 这个是对象的方式,消息的传递和接收都是fecshop的时候使用 // Yii::$app->queue->push(new PushTest([ // 'name' => 'terry', // 'age' => 31, // ])); // 这是一种比较随便的方式,发送的数组会以序列化的方式发送过去 // 传递的给MQ的个数格式为序列化数组。 Yii::$app->queue->push([ 'name' => 'terry', 'age' => 31, ]); }
测试
actionTest
php
fecshop/yii2_fecshop
app/console/modules/Amqp/controllers/TestController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Amqp/controllers/TestController.php
BSD-3-Clause
public function actionHome() { Yii::$service->sitemap->home(); }
首页
actionHome
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionCategorypagecount() { echo Yii::$service->sitemap->categorypagecount(); }
分类页面的页面总数
actionCategorypagecount
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionCategory($pageNum) { Yii::$service->sitemap->category($pageNum); }
生成分类页面
actionCategory
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionProductpagecount() { echo Yii::$service->sitemap->productpagecount(); }
产品页面的页面总数
actionProductpagecount
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionProduct($pageNum) { Yii::$service->sitemap->product($pageNum); }
生成产品页面
actionProduct
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionCmspagepagecount() { echo Yii::$service->sitemap->cmspagepagecount(); }
cms page页面的页面总数
actionCmspagepagecount
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionCmspage($pageNum) { Yii::$service->sitemap->cmspage($pageNum); }
生成cms page页面的sitemap
actionCmspage
php
fecshop/yii2_fecshop
app/console/modules/Sitemap/controllers/XmlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Sitemap/controllers/XmlController.php
BSD-3-Clause
public function actionSynccount() { $count = Yii::$service->product->collCount(); echo $count ; }
得到个数
actionSynccount
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/QtyController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/QtyController.php
BSD-3-Clause
public function actionSyncpagenum() { $count = Yii::$service->product->collCount(); echo ceil($count / $this->numPerPage); }
得到个数
actionSyncpagenum
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/QtyController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/QtyController.php
BSD-3-Clause
public function actionInitindex() { Yii::$service->search->initFullSearchIndex(); }
1.初始化mongodb表的索引。如果您已经有了text索引,然后想更改text索引 您需要去mongodb的各个语言表中将text索引删除,或者将各个搜索表删除。 当重新执行initmongoindex的时候就会重建text索引,否则会报错 在mongodb中text可以是多个字段组合,但是只能有一个text索引。 这也就是为什么要把各个语言分开成多个表的原因。 2.初始化其他表的索引.
actionInitindex
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/SearchController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/SearchController.php
BSD-3-Clause
public function actionDeletenotactiveproduct($nowTimeStamp) { Yii::$service->search->deleteNotActiveProduct($nowTimeStamp); }
@param $nowtime | Int 当前时间的时间戳 经过上面的批量更新,会更新updated_at字段,因此小于$nowtime的数据,会认为是无效 的字段了,因为上面的更新是批量更新。
actionDeletenotactiveproduct
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/SearchController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/SearchController.php
BSD-3-Clause
public function actionSynccount() { $count = Yii::$service->product->collCount(); echo $count ; }
得到个数
actionSynccount
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/MysqldatatomongoController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/MysqldatatomongoController.php
BSD-3-Clause
public function actionSyncpagenum() { $count = Yii::$service->product->collCount(); echo ceil($count / $this->numPerPage); }
得到个数
actionSyncpagenum
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/MysqldatatomongoController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/MysqldatatomongoController.php
BSD-3-Clause
public function actionSynccount() { $count = Yii::$service->product->collCount(); echo $count ; }
得到个数
actionSynccount
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/MongodatatomysqlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/MongodatatomysqlController.php
BSD-3-Clause
public function actionSyncpagenum() { $count = Yii::$service->product->collCount(); echo ceil($count / $this->numPerPage); }
得到个数
actionSyncpagenum
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/MongodatatomysqlController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/MongodatatomysqlController.php
BSD-3-Clause
public function actionProductcount() { //$filter['select'] = ['_id']; //$filter['where'][] = ['is_in_stock' => 1]; //$filter['where'][] = ['status' => 1]; $count = Yii::$service->product->collCount($filter); echo $count; }
得到产品的总数。
actionProductcount
php
fecshop/yii2_fecshop
app/console/modules/Product/controllers/PriceController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/console/modules/Product/controllers/PriceController.php
BSD-3-Clause
public function init() { parent::init(); /** * 如果模板路径没有配置,则配置模板路径 */ if (!Yii::$service->page->theme->fecshopThemeDir) { Yii::$service->page->theme->fecshopThemeDir = Yii::getAlias(CConfig::param('appfrontBaseTheme')); } /** * 如果layout文件没有配置,则配置layout文件 */ if (!Yii::$service->page->theme->layoutFile) { Yii::$service->page->theme->layoutFile = CConfig::param('appfrontBaseLayoutName'); } /* * set i18n translate category. */ Yii::$service->page->translate->category = 'appfront'; /* * 自定义Yii::$classMap,用于重写 */ }
init theme component property : $fecshopThemeDir and $layoutFile $fecshopThemeDir is appfront base theme directory. layoutFile is current layout relative path.
init
php
fecshop/yii2_fecshop
app/appfront/modules/AppfrontController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/AppfrontController.php
BSD-3-Clause
public function getBlock($blockName = '') { if (!$blockName) { $blockName = $this->action->id; } if (!$this->blockNamespace) { $this->blockNamespace = Yii::$app->controller->module->blockNamespace; } if (!$this->blockNamespace) { throw new \yii\web\HttpException(406, 'blockNamespace is empty , you should config it in module->blockNamespace or controller blockNamespace '); } $viewId = $this->id; $viewId = str_replace('/', '\\', $viewId); $relativeFile = '\\'.$this->blockNamespace; $relativeFile .= '\\'.$viewId.'\\'.ucfirst($blockName); //查找是否在rewriteMap中存在重写 $relativeFile = Yii::mapGetName($relativeFile); return new $relativeFile(); }
@param $blockName | String get current block 这个函数的controller中得到block文件,譬如: cms模块的ArticleController的actinIndex()方法中使用$this->getBlock()->getLastData()方法, 对应的是cms/block/article/Index.php里面的getLastData(), 也就是说,这个block文件路径和controller的路径有一定的对应关系 这个思想来自于magento的block。
getBlock
php
fecshop/yii2_fecshop
app/appfront/modules/AppfrontController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/AppfrontController.php
BSD-3-Clause
public function render($view, $params = []) { $viewFile = Yii::$service->page->theme->getViewFile($view); $content = Yii::$app->view->renderFile($viewFile, $params, $this); return $this->renderContent($content); }
@param $view|string , (only) view file name ,by this module id, this controller id , generate view relative path. @param $params|Array, 这个是fecshop重写的render函数,根据fecshop的多模板机制 首先在高级别的模板中找view文件,如果找不到,按照模板路径优先级依次查找 直到找到view'文件。 1.get exist view file from mutil theme by theme protity. 2.get content by yii view compontent function renderFile() ,
render
php
fecshop/yii2_fecshop
app/appfront/modules/AppfrontController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/AppfrontController.php
BSD-3-Clause
public function findLayoutFile($view) { $layoutFileStr = Yii::$service->page->theme->layoutFile; if (substr($layoutFileStr, 0, 1) == '@') { return Yii::getAlias($layoutFileStr); } $layoutFile = ''; $relativeFile = 'layouts/'.Yii::$service->page->theme->layoutFile; $absoluteDir = Yii::$service->page->theme->getThemeDirArr(); foreach ($absoluteDir as $dir) { if ($dir) { $file = $dir.'/'.$relativeFile; if (file_exists($file)) { $layoutFile = $file; return $layoutFile; } } } throw new InvalidValueException('layout file is not exist!'); }
@param $view|string Get current layoutFile absolute path from mutil theme dir by protity. 首先在高级别的模板中找view文件,如果找不到,按照模板路径优先级依次查找 直到找到view'文件。
findLayoutFile
php
fecshop/yii2_fecshop
app/appfront/modules/AppfrontController.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/AppfrontController.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['customer_address_edit_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/address/Edit.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/address/Edit.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['customer_address_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/address/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/address/Index.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['customer_order_info_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/order/View.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/order/View.php
BSD-3-Clause
public function errorMessage($message) { Yii::$service->page->message->addError($message); return Yii::$service->url->redirectByUrlKey('customer/order'); }
@param $message | String 添加报错信息
errorMessage
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/order/Reorder.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/order/Reorder.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['customer_order_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/order/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/order/Index.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['customer_product_review_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/productreview/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/productreview/Index.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['customer_product_favorite_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/productfavorite/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/productfavorite/Index.php
BSD-3-Clause
public function remove($favorite_id) { Yii::$service->product->favorite->currentUserRemove($favorite_id); }
@param $favorite_id|string
remove
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/productfavorite/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/productfavorite/Index.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['account_information_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/editaccount/Index.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/editaccount/Index.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['forgot_reset_password_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Registerenable.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Registerenable.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['forgot_password_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Forgotpassword.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Forgotpassword.php
BSD-3-Clause
public function sendForgotPasswordEmail($identity) { if ($identity) { Yii::$service->email->customer->sendForgotPasswordEmail($identity); } }
发送忘记密码邮件.
sendForgotPasswordEmail
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Forgotpassword.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Forgotpassword.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['login_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Login.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Login.php
BSD-3-Clause
public function sendLoginEmail($param) { if ($param) { Yii::$service->email->customer->sendLoginEmail($param); } }
发送登录邮件.
sendLoginEmail
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Login.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Login.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['register_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Register.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Register.php
BSD-3-Clause
public function sendRegisterEmail($param) { if ($param) { //Email::sendRegisterEmail($param); if (Yii::$service->email->customer->registerAccountIsNeedEnableByEmail) { $registerEnableToken = Yii::$service->customer->generateRegisterEnableToken($param['email']); if ($registerEnableToken) { $param['register_enable_token'] = $registerEnableToken; Yii::$service->email->customer->sendRegisterEmail($param); return true; } } else { Yii::$service->email->customer->sendRegisterEmail($param); return true; } } }
发送登录邮件.
sendRegisterEmail
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Register.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Register.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['forgot_reset_password_success_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Resetpasswordsuccess.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Resetpasswordsuccess.php
BSD-3-Clause
protected function breadcrumbs($name) { if (Yii::$app->controller->module->params['forgot_reset_password_breadcrumbs']) { Yii::$service->page->breadcrumbs->addItems(['name' => $name]); } else { Yii::$service->page->breadcrumbs->active = false; } }
面包屑导航
breadcrumbs
php
fecshop/yii2_fecshop
app/appfront/modules/Customer/block/account/Resetpassword.php
https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/account/Resetpassword.php
BSD-3-Clause