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


PHP Family::UpdateChildCount方法代码示例

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


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

示例1: save_product


//.........这里部分代码省略.........
         $objProduct->inventory_avail = $fltInventory - $fltReserved;
     }
     //Because Lightspeed may send us products out of sequence (child before parent), we have to turn this off
     Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=0;')->execute();
     if (!$objProduct->save()) {
         Yii::log("SOAP ERROR : Error saving product {$intRowid} {$strCode} " . print_r($objProduct->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return self::UNKNOWN_ERROR . " Error saving product {$intRowid} {$strCode} " . print_r($objProduct->getErrors(), true);
     }
     $strFeatured = _xls_get_conf('FEATURED_KEYWORD', 'XnotsetX');
     if (empty($strFeatured)) {
         $strFeatured = 'XnotsetX';
     }
     //Save keywords
     $strTags = trim($strWebKeyword1) . "," . trim($strWebKeyword2) . "," . trim($strWebKeyword3);
     $strTags = str_replace(",,", ",", $strTags);
     $arrTags = explode(",", $strTags);
     ProductTags::DeleteProductTags($objProduct->id);
     foreach ($arrTags as $indivTag) {
         if (!empty($indivTag)) {
             $tag = Tags::model()->findByAttributes(array('tag' => $indivTag));
             if (!$tag instanceof Tags) {
                 $tag = new Tags();
                 $tag->tag = $indivTag;
                 $tag->save();
             }
             $objProductTag = new ProductTags();
             $objProductTag->product_id = $objProduct->id;
             $objProductTag->tag_id = $tag->id;
             $objProductTag->save();
             if ($strFeatured != 'XnotsetX' && $objProduct->web && $indivTag == $strFeatured) {
                 $objProduct->featured = 1;
                 $objProduct->save();
             }
         }
     }
     if (!empty($strFamily)) {
         $objFamily = Family::model()->findByAttributes(array('family' => $strFamily));
         if ($objFamily instanceof Family) {
             $objProduct->family_id = $objFamily->id;
             $objProduct->save();
         } else {
             $objFamily = new Family();
             $objFamily->family = $strFamily;
             $objFamily->child_count = 0;
             $objFamily->request_url = _xls_seo_url($strFamily);
             $objFamily->save();
             $objProduct->family_id = $objFamily->id;
             $objProduct->save();
         }
         $objFamily->UpdateChildCount();
     } else {
         if ($objProduct->family_id) {
             $objFamily = Family::model()->findByAttributes(array('id' => $objProduct->family_id));
             $objProduct->family_id = null;
             $objProduct->save();
             $objFamily->UpdateChildCount();
         }
     }
     if (!empty($strClassName)) {
         $objClass = Classes::model()->findByAttributes(array('class_name' => $strClassName));
         if ($objClass instanceof Classes) {
             $objProduct->class_id = $objClass->id;
             $objProduct->save();
         } else {
             $objClass = new Classes();
             $objClass->class_name = $strClassName;
             $objClass->child_count = 0;
             $objClass->request_url = _xls_seo_url($strClassName);
             $objClass->save();
             $objProduct->class_id = $objClass->id;
             $objProduct->save();
         }
         $objClass->UpdateChildCount();
     }
     // Save category
     $strCategoryPath = trim($strCategoryPath);
     if ($strCategoryPath && $strCategoryPath != "Default") {
         $arrCategories = explode("\t", $strCategoryPath);
         $intCategory = Category::GetIdByTrail($arrCategories);
         if (!is_null($intCategory)) {
             $objCategory = Category::model()->findByPk($intCategory);
             //Delete any prior categories from the table
             ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id));
             $objAssn = new ProductCategoryAssn();
             $objAssn->product_id = $objProduct->id;
             $objAssn->category_id = $intCategory;
             $objAssn->save();
             $objCategory->UpdateChildCount();
         }
     } else {
         ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id));
     }
     Product::convertSEO($intRowid);
     //Build request_url
     Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=1;')->execute();
     $objEvent = new CEventProduct('LegacysoapController', 'onSaveProduct', $objProduct);
     _xls_raise_events('CEventProduct', $objEvent);
     //
     return self::OK;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:101,代码来源:LegacysoapController.php


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