array_push($stack, $line_of_text); } } fclose($handle); $count = count($stack); echo '<br>Count:' . $count; for ($i = 0; $i < $count; $i++) { $where = global_mapping::ArticleTypeID . '=' . $stack[$i][4] . ' and ' . global_mapping::PropertyGroupName . '=\'' . trim($stack[$i][1]) . '\''; $existedGroups = $objPropertyGroup->getAllPropertyGroup(0, '*', $where, ''); if (count($existedGroups) <= 0) { $groupID = $objPropertyGroup->insert($stack[$i][1], $stack[$i][1], $stack[$i][4], $i + 10, $createdBy); } else { $groupID = $existedGroups[0][0]; } $where = global_mapping::PropertyGroupID . '=' . $groupID . ' and ' . global_mapping::PropertyName . '=\'' . trim($stack[$i][0]) . '\''; $existedProperties = $objProperty->getAllProperty(0, '*', $where, ''); if (count($existedProperties) <= 0) { $objProperty->insert($groupID, $stack[$i][0], $stack[$i][2], 1, $stack[$i][3], $createdBy, 1); echo 'Inserted a new property ' . $stack[$i][0] . ' Group:' . $stack[$i][1] . 'Cat: ' . $stack[$i][4]; echo "<br>"; } else { echo 'Existed property ' . $stack[$i][0] . ' Group:' . $stack[$i][1] . 'Cat: ' . $stack[$i][4]; echo "<br>"; } //$stack[$i][4] = 1; } /*$fp = fopen($filePath, 'w'); fputcsv($fp, array('ID','Name','Address','Email','Sent')); foreach ($stack as $item) { fputcsv($fp, $item); }
public function getTopPropertyValue($catID, $sizeProperty, $sizeValue) { $whereClause = 'WHERE ' . global_mapping::ArticleTypeID . ' = \'' . $catID . '\' '; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', Model_PropertyGroup::TBL_SL_PROPERTY_GROUP, $whereClause)); $propertyGroups = $this->_objConnection->selectCommand($strSQL); //print_r($propertyGroups); $arrPropertyGroupIDs = global_common::getArrayColumn($propertyGroups, global_mapping::PropertyGroupID); $strQueryIN = global_mapping::PropertyGroupID . ' IN(' . global_common::convertToQueryIN($arrPropertyGroupIDs) . ')'; //echo $strQueryIN; $objProperty = new Model_Property($this->_objConnection); $allProperties = $objProperty->getAllProperty(0, '*', $strQueryIN, '`Order`'); $arrPropertyIDs = global_common::getArrayColumn($allProperties, global_mapping::PropertyID); //print_r($allProperties); $strQueryIN = global_mapping::PropertyID . ' IN(' . global_common::convertToQueryIN($arrPropertyIDs) . ')'; $temp = array(); foreach ($allProperties as $key => $info) { $temp[$info[global_mapping::PropertyID]] = $info; unset($allProperties[$key]); } $allProperties = $temp; //print_r($allProperties); //get top properties used $strQueryIN = global_mapping::PropertyID . ' IN(' . global_common::convertToQueryIN($arrPropertyIDs) . ')'; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array(PropertyID, self::TBL_SL_PRODUCT_PROPERTY, 'WHERE ' . $strQueryIN . ' GROUP BY PropertyID ORDER BY COUNT(*) DESC LIMIT 0,' . $sizeProperty . '')); //echo '<br>SQL:'.$strSQL; $arrTopPropertyIDs = $this->_objConnection->selectCommand($strSQL); if (!$arrTopPropertyIDs || count($arrTopPropertyIDs) <= 0) { return; } //print_r($arrTopPropertyIDs); $arrTopPropertyIDs = global_common::getArrayColumn($arrTopPropertyIDs, global_mapping::PropertyID); $strQueryIN = 'WHERE ' . global_mapping::PropertyID . ' IN(' . global_common::convertToQueryIN($arrTopPropertyIDs) . ')'; $strQueryIN .= ' Group By ' . global_mapping::PropertyID . ',' . global_mapping::PropertyValue; $strQueryIN .= ' Order By ' . global_mapping::PropertyID . ',COUNT(' . global_mapping::PropertyValue . ') DESC'; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('distinct ' . global_mapping::PropertyID . ',' . global_mapping::PropertyValue, self::TBL_SL_PRODUCT_PROPERTY, $strQueryIN)); //echo '<br>SQL:'.$strSQL; $arrTopProperties = $this->_objConnection->selectCommand($strSQL); //print_r($arrTopProperties); $arrResult = array(); foreach ($arrTopPropertyIDs as $item) { //echo $item; $arrResult[$item] = $allProperties[$item]; $arrValue = array(); $limit = $sizeValue; //print_r($arrTopProperties); //echo ' PropID:'.$item; foreach ($arrTopProperties as $value) { if ($value[global_mapping::PropertyID] == $item && $limit > 0) { //echo $value[global_mapping::PropertyValue]; //echo $value[global_mapping::PropertyValue]; $arrValue = array_merge($arrValue, array($value[global_mapping::PropertyValue])); $limit--; } } //print_r($arrValue); $arrResult[$item][global_mapping::PropertyValue] = $arrValue; } //print_r($arrResult); return $arrResult; }
$objManufactory = new Model_Manufactory($objConnection); //$propertyInfo = $objProduct->getPropertyInfoByID(30); //print_r($propertyInfo); $intMode = 0; //add mode $parentTypes = $objArticleType->getAllArticleType(0, null, 'ParentID=0', 'Level'); $allTypes = $objArticleType->getAllArticleType(0, null, 'ParentID!=0', 'Level'); //set default selected section $currentParentType = $parentTypes[0][global_mapping::ArticleTypeID]; $allGroups = $objPropertyGroup->getAllPropertyGroup(0, '*', '', ''); $allManuFactories = $objManufactory->getAllManufactory(0, '*', '', global_mapping::ManufactoryName); //print_r($allGroups); $allGroupIDs = global_common::getArrayColumn($allGroups, global_mapping::PropertyGroupID); $strQueryIN = global_mapping::PropertyGroupID . ' IN(' . global_common::convertToQueryIN($allGroupIDs) . ')'; //echo($allCities); $allProperties = $objProperty->getAllProperty(0, '*', $strQueryIN, '`Order`'); //print_r($allProperties); if ($_pgR["pid"]) { $productID = $_pgR["pid"]; $product = $objProduct->getProductByID($productID); $intMode = 1; //edit mode $createBy = $product[global_mapping::CreatedBy]; $currentUserID = $_SESSION[global_common::SES_C_USERINFO][global_mapping::UserID]; if ($createBy != $currentUserID) { global_common::redirectByScript("index.php"); return; } //print_r($article[global_mapping::ArticleID]); $currentTypeID = $product[global_mapping::CatalogueID]; //print_r($product);