小编Cha*_*Dou的帖子

通过jQuery Ajax发送Json数组

我将通过jquery ajax调用发送一个json对象数组到一个php文件.

var arr = new Array();
var record1 = {'a':'1','b':'2','c':'3'};
var record2 = {'d':'4','e':'5','f':'6'};
arr.push(record1);
arr.push(record2);
Run Code Online (Sandbox Code Playgroud)

如何通过jquery ajax发送数组?我怎样才能在php中获取值?谢谢.

php jquery json getjson

4
推荐指数
1
解决办法
2万
查看次数

使用 imagemagick 旋转透明 gif

我将用透明颜色旋转 gif 图像。但旋转后,图像失去透明度,背景不透明。我怎样才能正确地使用透明颜色和透明背景呢?

这是我的命令:

convert test.gif -alpha set -rotate 30 -background transparent rotate.gif
Run Code Online (Sandbox Code Playgroud)

谢谢。

imagemagick gif rotation transparent

3
推荐指数
1
解决办法
2722
查看次数

以编程方式创建Magento产品

我正在做一个以编程方式添加Magento产品的项目.这是代码段

try{
    //create new product
    $newProduct = new Mage_Catalog_Model_Product();
    $newProduct->setAttributeSetId(9)
               ->setTypeId('simple')
               ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
               ->setTaxClassId(2)
               ->setCreatedAt(strtotime('now'))
               ->setName($data[0])
               ->setSku($data[1])
               ->setWeight($data[2])
               ->setStatus($data[3])
               ->setPrice($data[4])
               ->setCategoryIds(explode(',',$data[5]))
               ->setWebsiteIds(explode(',',$data[6]))
               ->setDescription($data[7])
               ->setShortDescription($data[8])
                               ....
               ->setFreeGroundShipping($data[18])
               ->setMetaTitle($data[19])
               ->setMetaKeyword($data[20])
               ->setMetaDescription($data[21])
               ->setStockData(array(
                                     'manage_stock'=>0,
                                     'min_sale_qty'=>$data[22],
                                     'max_sale_qty'=>$data[23]))
               ->setSetupFee($data[24])
               ->setsetupCost($data[25]);
    $newProduct->save();                
}catch(Exception $e){
     $result['status'] = 3;
     $result['message'] = 'There is an ERROR happened! NOT ALL products are created! Error:'.$e->getMessage();
     echo json_encode($result);
     return;
}
Run Code Online (Sandbox Code Playgroud)

问题出在这里:执行代码后,我回到magento管理产品,产品已经创建,但是一些"商店视图"属性是空的!我进入数据库,发现所有属性都有值.

有没有人知道如何制作出场景?非常感谢!

magento magento-1.6

3
推荐指数
1
解决办法
6310
查看次数

fgetcsv()为每一行返回"true"

我有php fgetcsv()方法的问题.我只能得到值"1"而不是每行的数组.这是代码:

$row = 0;
$teststring='';
$handle = fopen($savepath,'r');
if($handle!==FALSE){
    while(($data = fgetcsv($handle,2000,'|')!==FALSE)){        //I am using '|' as the delimiter
        echo (string)$data;
        if($row!=0){
            foreach($data as $d){
                array_push($result['added'],$d);
            }
        }
        $row++;
    }
    fclose($handle);
}
Run Code Online (Sandbox Code Playgroud)

我测试了一个3行的csv文件,结果将是"111".当然,数组$ result ['added']没有值.任何人都可以知道发生了什么吗?谢谢.

php fgetcsv

2
推荐指数
1
解决办法
1854
查看次数