使用Mamgi导入magento可筛选的select属性字段注意

注:本文针对的情况为Magento属性集(Attribute sets)和属性为程序批量添加的情况。如果是后台手动添加则没有这种问题。

例如csv文件的导入格式为:

"sku","store",....,"myselect"
"sku1","admin",....,"value1"
"sku2","admin",....,"value3"

这里的myselect为Magento新建的attribute,下拉可筛选的select

不同于使用magento自己的导入程序规范的csv文件格式,使用MAMGI导入的话需要更改 "value1" "value3" ..,为对应的属性字段的option的id。

可使用一下magento代码查询并替换:

$productModel = Mage::getModel('catalog/product');
$attr = $productModel->getResource()->getAttribute(" myselect
 ");
if ($attr->usesSource()) {
   $value_id = $attr->getSource()->getOptionId("value1");
}

这里的value_id的值替换"value1"再用Mamgi导入一遍即可。

Ps 泥马 被这问题吭了一天。。

备忘

GROUP_CONCAT :SELECT GROUP_CONCAT( access.amid ) AS mid FROM wms.access WHERE access.agid=0

以下代码可以取某个范围内的列名,下例中是取5到10列的列名。
select * from INFORMATION_SCHEMA.COLUMNS where table_name='HX' and ordinal_position between 5 and 10

js 数字
<input name="end_price" id="end_price" type="text" size="5" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" >


SELECT GROUP_CONCAT(mname) from webinfo.mod


批量替换
UPDATE article(表) SET
content = replace(content, ’解决’, ’解放’)
WHERE ID<5000;

查找字段的字符
SELECT a.products_name FROM nikefed.products_description a WHERE a.products_name like '%#%'

大写变小写
strtolower

<fieldset>
    <legend><span>fieldset</span></legend>
<form></form>
</fieldset>

图片与文字水平对齐
图片加:align="absmiddle"

图片hack:margin-bottom:-3px;

<div id="output" style="border:1px solid gray;width:95%;height:400;overflow-y:scroll"></div>


CREATE VIEW qd
AS
(SELECT a.aid, b.bid,b.bfield,c.cvalue
    FROM (a, b ) 
    LEFT JOIN c 
    ON (a.aid = c.aid AND b.bid = c.bid) 
    ORDER BY a.aid ASC, b.bid ASC
);
SELECT a.* FROM qd a
LEFT JOIN
(
SELECT a.aid,a.ma,COUNT(b.aid) AS dd FROM (SELECT aid,MAX(cvalue) AS ma FROM qd GROUP BY aid) a
LEFT JOIN (SELECT aid,MAX(cvalue) AS ma FROM qd GROUP BY aid) b
ON a.ma>=b.ma
GROUP BY a.aid,a.ma
ORDER BY COUNT(b.aid)) d
ON a.aid=d.aid
ORDER BY d.dd;


301
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.nkfed.com/");


Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6144 bytes)  修改php.ini 的memory_limit的值更大点。

桌面url快捷方式  命名为**.url
[DEFAULT]
BASEURL=http://i.hudong.com/home.do
[InternetShortcut]
URL=http://i.hudong.com/home.do
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2


js操作换行
<script type="text/javascript">
// <![CDATA[
function toBreakWord(intLen){
    var obj=document.getElementsByName("ff");
    for(var i=0;i<obj.length;i++){
        var strContent=obj[i].innerHTML; 
        var strTemp="";
        while(strContent.length>intLen){
        strTemp+=strContent.substr(0,intLen)+"&#10;"; 
        strContent=strContent.substr(intLen,strContent.length); 
        }
        strTemp+="&#10;"+strContent;
        obj[i].innerHTML=strTemp;
    }
}
if(document.getElementById  &&  !document.all)  toBreakWord(37);
// ]]>
</script>


错误调试
//使用html格式的错误输出内容,比较重要,否则在页面上就乱了
ini_set('html_errors', 1);
//打开所有的错误级别
ini_set('error_reporting', E_ALL);
//显示错误
ini_set('display_errors', 1);
//显示启动错误 推荐在各个业务的入php文件中设置,而不要在php.ini中设置。
ini_set('display_startup_errors', 1);


取分类的头几条记录
Select   *   From   表   A
Where   (Select   Count(*)   From   表   Where   type   =   A.type   And   value   <   A.value)   <   2
Order   By   type,   value



    function get_Curr_Domain() {
        $HTTP_HOST = PMA_getenv('HTTP_HOST');echo $HTTP_HOST.'<br>';
        $HTTP_HOST = strrev($HTTP_HOST);echo $HTTP_HOST.'<br>';
        $HTTP_HOST = explode('.',$HTTP_HOST,3);dump($HTTP_HOST);
        $curr_Domain = htmlspecialchars(strrev($HTTP_HOST[0].'.'.$HTTP_HOST[1]));
        return  $curr_Domain;
    }


linux打包
 tar -cvfz /var/www/html/gamestore8-6.tar.gz /var/www/html/gamestore.com

zip –q –r html.zip html

  $ cp - i exam1.c /usr/wang/shiyan1.c
  该命令将文件exam1.c拷贝到/usr/wang 这个目录下,并改名为 shiyan1.c。若不希望重新命名,可以使用下面的命令:
  $ cp exam1.c /usr/ wang/
  $ cp - r /usr/xu/ /usr/liu/ 将/usr/xu目录中的所有文件及其子目录拷贝到目录/usr/liu中

select组
<select>
    <optgroup label="<5" >
        <option>0</option>
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
    </optgroup>
    <optgroup label=">4" >
        <option>5</option>
        <option>6</option>
        <option>7</option>
        <option>8</option>
        <option>9</option>
    </optgroup>
</select>

chmod g+ order_doc

启动apache
service httpd start
启动FTP
service vsftpd restart
启动mysql
service mysqld restart

手型
style="cursor: pointer" mce_style="cursor: pointer"

MSN:   <a href="msnim:chat?contact=sales_support@hotmail.com">sales_support@hotmail.com</a>
EMAIL: <a href="mailto:support@tiffanyouth.co.uk">support@tiffanyouth.co.uk</a>

//编码转换:         内容    to     from
mb_convert_encoding($data,'utf-8','gbk')

$  USD   美元
£ GBP   英镑
€  EUR   欧元

监听回车
<script language="javascript">
 function keypress(e)
  {
    var currKey=0,e=e||event;
      if(e.keyCode==13)document.myform.submit();
  }
 document.onkeypress=keypress;
  </script>

  addslashes<==>stripcslashes

jquery查找和替换
t:要查找替换的字符串 
$.each(t, function(k, v) {
    /^[A-Za-z0-9]$/.exec(v) || (t=t.replace(t[k],'-'));
});

select下拉框的第二个元素为当前选中值
$('#select_id')[0].selectedIndex = 1;

radio单选组的第二个元素为当前选中值
$('input[@name=items]').get(1).checked = true;

获取select被选中项的文本
var item = $("#gp_pid option:selected").text();
var item = $("select[@name=items] option[@selected]").text();

$("#sel").attr("value",'-sel3');//设置value=-sel3的项目为当前选中项

单选组radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项

$("#select_id").attr("value",'test');//设置value=test的项目为当前选中项

js获取时间
new Date().getTime()
Math.random();

//随机输出
if(!flag){
    var words=[
        {image:0,head:"msg1",body:"cnt1"},
        {image:1,head:"msg2",body:"cnt2"},
        {image:2,head:"msg3",body:"cnt3"},
        {image:"mini",head:"",body:""}];
    var rand = new Date().getTime() % 3;
    var content =
    '<div>'.words[rand].image+'.jpg'+
        '<h2>'+words[rand].head+'</h2>'+
        '<p>'+words[rand].body+'</p>'+
    '</div>';
    document.write(content);
}

//js加载块内容的方式
<div class="login_inner">
<script type="text/javascript">
    document.write('<iframe id="login_iframe" style="height:300px;width:366px;" class="loginIframe" frameborder="no" scrolling="no" src="#"></iframe>');
</script>
</div>

js设置样式
if ( is_IE ){
document.getElementById(controlID).className = controlCssClass ;
}
else if ( is_NN ){
document.getElementById(controlID).setAttribute("class", controlCssClass) ;
}

jquery 验证email
 var search_str = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
 var email_val = $("#Email").val();
 if(!search_str.test(email_val)){      
 alert("please input right email !");
 $('#Email').focus();
 return false;
 }

PHP数据库操作类 - ezSQL

ezSQL 下载地址://sjolzy.cn/php/ezSQL/bak/ez_sql_2.05.zip

新版本是2.05添加了很多支持,包括 CodeIgniter,MSSQL, PDO等等。

查看示例:

Example 1
----------------------------------------------------

// Select multiple records from the database and print them out..
$users = $db->get_results("SELECT name, email FROM users");
foreach ( $users as $user ) {
            // Access data using object syntax
            echo $user->name;
            echo $user->email;
}

Example 2
----------------------------------------------------

// Get one row from the database and print it out..
$user = $db->get_row("SELECT name,email FROM users WHERE id = 2");
echo $user->name;
echo $user->email;

Example 3
----------------------------------------------------

// Get one variable from the database and print it out..
$var = $db->get_var("SELECT count(*) FROM users");
echo $var;

Example 4
----------------------------------------------------

// Insert into the database
$db->query("INSERT INTO users (id, name, email) VALUES (NULL,'justin','jv@foo.com')");

Example 5
----------------------------------------------------

// Update the database
$db->query("UPDATE users SET name = 'Justin' WHERE id = 2)");

Example 6
----------------------------------------------------

// Display last query and all associated results
$db->debug();

Example 7
----------------------------------------------------

// Display the structure and contents of any result(s) .. or any variable
$results = $db->get_results("SELECT name, email FROM users");
$db->vardump($results);

Example 8
----------------------------------------------------

// Get 'one column' (based on column index) and print it out..
$names = $db->get_col("SELECT name,email FROM users",0)
foreach ( $names as $name ) {
    echo $name;
}

Example 9
----------------------------------------------------

// Same as above ‘but quicker’
foreach ( $db->get_col("SELECT name,email FROM users",0) as $name ) {
    echo $name;
}

Example 10
----------------------------------------------------

// Map out the full schema of any given database and print it out..
$db->select("my_database");
foreach ( $db->get_col("SHOW TABLES",0) as $table_name ) {
    $db->debug();
    $db->get_results("DESC $table_name");
}
$db->debug();

 

js select操作大全及select下拉列表分组

js 代码
// 1.判断select选项中 是否存在Value="paraValue"的 Item
function jsSelectIsExitItem(objSelect, objItemValue) {
var isExit = false;
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
isExit = true;
break;
}
}
return isExit;
}

// 2.向select选项中 加入一个Item
function jsAddItemToSelect(objSelect, objItemText, objItemValue) {
//判断是否存在
if (jsSelectIsExitItem(objSelect, objItemValue)) {
alert("该Item的Value值已经存在");
} else {
var varItem = new Option(objItemText, objItemValue);
objSelect.options.add(varItem);
alert("成功加入");
}
}

// 3.从select选项中 删除一个Item
function jsRemoveItemFromSelect(objSelect, objItemValue) {
//判断是否存在
if (jsSelectIsExitItem(objSelect, objItemValue)) {
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
objSelect.options.remove(i);
break;
}
}
alert("成功删除");
} else {
alert("该select中 不存在该项");
}
}


// 4.删除select中选中的项
function jsRemoveSelectedItemFromSelect(objSelect) {
var length = objSelect.options.length - 1;
for(var i = length; i >= 0; i--){
if(objSelect[i].selected == true){
objSelect.options[i] = null;
}
}
}

// 5.修改select选项中 value="paraValue"的text 为"paraText"
function jsUpdateItemToSelect(objSelect, objItemText, objItemValue) {
//判断是否存在
if (jsSelectIsExitItem(objSelect, objItemValue)) {
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
objSelect.options[i].text = objItemText;
break;
}
}
alert("成功修改");
} else {
alert("该select中 不存在该项");
}
}

// 6.设置select中text="paraText"的第一个Item为选中
function jsSelectItemByValue(objSelect, objItemText) {
//判断是否存在
var isExit = false;
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].text == objItemText) {
objSelect.options[i].selected = true;
isExit = true;
break;
}
}
//Show出结果
if (isExit) {
alert("成功选中");
} else {
alert("该select中 不存在该项");
}
}

// 7.设置select中value="paraValue"的Item为选中
document.all.objSelect.value = objItemValue;

// 8.得到select的当前选中项的value
var currSelectValue = document.all.objSelect.value;

// 9.得到select的当前选中项的text
var currSelectText = document.all.objSelect.options[document.all.objSelect.selectedIndex].text;

// 10.得到select的当前选中项的Index
var currSelectIndex = document.all.objSelect.selectedIndex;

// 11.清空select的项
document.all.objSelect.options.length = 0;

 

分组:

<select>
<optgroup label="<5" >
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</optgroup>
<optgroup label=">4" >
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</optgroup>
</select>

mysql多表联结查询

MySQL支持Select和某些Update和Delete情况下的Join语法,具体语法上的细节有:

 table_references:

    table_reference [, table_reference] …

 table_reference:

    table_factor

  | join_table

 table_factor:

    tbl_name [[AS] alias]

        [{USE|IGNORE|FORCE} INDEX (key_list)]

  | ( table_references )

  | { OJ table_reference LEFT OUTER JOIN table_reference

        ON conditional_expr }

 join_table:

    table_reference [INNER | CROSS] JOIN table_factor [join_condition]

  | table_reference STRAIGHT_JOIN table_factor

  | table_reference STRAIGHT_JOIN table_factor ON condition

  | table_reference LEFT [OUTER] JOIN table_reference join_condition

  | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor

  | table_reference RIGHT [OUTER] JOIN table_reference join_condition

  | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor

 join_condition:

    ON conditional_expr | USING (column_list)

 

SELECT * FROM t1 LEFT JOIN (t2, t3, t4) ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)