我很困惑的是一个地产代理vebra导入脚本,它在移动到另一台服务器之前工作正常,但现在这似乎根本不起作用.
有谁知道为什么我会得到以下警告......
警告:ftp_get()[function.ftp-get]:打开文件传输的数据通道.在第37行的/home/username/public_html/includes/cron/import/vebra-import.php中
警告:ftp_get()[function.ftp-get]:在第37行的/home/username/public_html/includes/cron/import/vebra-import.php中转移确定
这是ftp连接代码:
$ftp = ftp_connect($ftp_host, 21) or die("FTP Connection Error");
ftp_login($ftp, $ftp_user, $ftp_pass) or die("Can't Connect to FTP");
$ftpdir = ftp_nlist($ftp, "/");
if(!empty($ftpdir) && count($ftpdir) > 0) {
foreach($ftpdir as $ftpfile) {
if(preg_match("/\.txt$/", $ftpfile)) {
$getfile = ftp_get($ftp, $csv_dir.$ftpfile, $ftpfile, FTP_BINARY);
if($getfile){
$downloaded++;
}
$total++;
}
}
}
ftp_close($ftp);
Run Code Online (Sandbox Code Playgroud)
此外,它似乎是间歇性的,有时这会成功执行,有时它会因上述错误而失败.
我需要一些帮助.我已经在magento中创建了一个需要与多个表交互的自定义模块.
我使用以下内容来获取表名
<entities>
<support1>
<table>table1</table>
</support1>
<support2>
<table>table2</table>
</support2>
<support3>
<table>table3</table>
</support3>
</entities>
Run Code Online (Sandbox Code Playgroud)
然后我将以下内容添加到我的模型中
public function _construct()
{
parent::_construct();
$this->_init('support/support1');
$this->_init('support/support2');
$this->_init('support/support3');
}
Run Code Online (Sandbox Code Playgroud)
在mysql4文件夹中我有......
public function _construct()
{
$this->_init('support/support1', 'ticket_id');
$this->_init('support/support2', 'dept_id');
$this->_init('support/support3', 'priority_id');
}
Run Code Online (Sandbox Code Playgroud)
而在Collection.php我有...
public function _construct()
{
parent::_construct();
$this->_init('support/support1');
$this->_init('support/support2');
$this->_init('support/support3');
}
Run Code Online (Sandbox Code Playgroud)
所以使用
$collection = Mage::getModel('support/support')->getCollection();
Run Code Online (Sandbox Code Playgroud)
我如何定义对support1或support2等的访问权限.我试过使用...
$collection = Mage::getModel('support/support1')->getCollection();
Run Code Online (Sandbox Code Playgroud)
和
$collection = Mage::getModel('support/support')->getCollection('support1');
Run Code Online (Sandbox Code Playgroud)
但两者都失败了,这怎么可能起作用?
提前致谢.
我使用placeholders.js,但我在控制台中收到以下错误...
[Error] TypeError: 'undefined' is not a function (evaluating 'Placeholders.init({
live: true,
hideOnFocus: false,
className: "yourClass",
textColor: "#999"
})')
complete (main.js, line 416)
j (modernizr.js, line 4)
(anonymous function) (modernizr.js, line 4)
h (modernizr.js, line 4)
onload (modernizr.js, line 4)
Run Code Online (Sandbox Code Playgroud)
这是我围绕这些线的代码,任何人都可以看到这是错误的我现在已经尝试了几个小时,我只是无法理解它.
if (!Modernizr.placeholder) {
Placeholders.init({
live: true,
hideOnFocus: false,
className: "yourClass",
textColor: "#999"
});
}
Run Code Online (Sandbox Code Playgroud) 嗨,我希望有人可以帮助我.我已经创建了一个自动产品导入程序脚本,它可以以编程方式添加产品和类别.我唯一的问题是它没有设置库存,当你进入CMS的后端时,产品列出了manage stock = no,因此它没有设置数量.我使用magento 1.9.0.1
有人可以指出我在这里缺少的东西,这是我的代码......
$newProduct->setAttributeSetId(4)
->setTypeId('simple')
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setTaxClassId(2)
->setCreatedAt(strtotime('now'))
->setName($product["ItemTitle"])
->setEannumber($product["EANNumber"])
->setWeight($product["Weight"])
->setStatus(1)
->setPrice($product["Price"])
->setCategoryIds($CategoryIDs)
->setWebsiteIds(array(1))
->setSku($product["ItemCode"])
->setDistributor('entatech')
->setDescription($productDescription2)
->setShortDescription($productDescriptionone)
->setMetaTitle($product["ItemTitle"])
->setMetaKeyword($prodKeywords)
->setMetaDescription($product["description2"]);
$newProduct->setCreatedAt(strtotime('now'));
$newProduct->setStockData(array(
'use_config_manage_stock' => 1,
'is_in_stock' => 1,
'qty' => $product["Stock"],
'manage_stock' => 1,
'use_config_notify_stock_qty' => 0
));
$newProduct->getResource()->save($newProduct);
Run Code Online (Sandbox Code Playgroud) 我已经搜索过,但一无所获。
我想要一些关于如何搜索多维数组并在值存在时更新或在值不存在时插入的建议或指针。
例如。目前我用这些值创建了一个数组,如下所示:
Array
(
[0] => Array
(
[quantity] => 1
[supplier_paypal] => paypalaccount1@paypal.com
[supplier_price] => 10
)
[1] => Array
(
[quantity] => 2
[supplier_paypal] => paypalaccount2@paypal.com
[supplier_price] => 20
)
)
Run Code Online (Sandbox Code Playgroud)
现在这很好,但它只是循环并且可以在数组中创建重复的电子邮件地址。我需要一些可以放在循环中的东西,用于搜索以查看电子邮件是否存在,如果存在,则只需将供应商价格相加即可。
任何帮助或想法?
这是我尝试过的:
$arrIt = new RecursiveIteratorIterator(
new RecursiveArrayIterator($this->data['payrecipient_data']));
foreach ($arrIt as $sub) {
$subArray = $arrIt->getSubIterator();
if ($subArray['supplier_paypal'] === $supplier_info['supplier_paypal']) {
$this->data['payrecipient_dup'][] = iterator_to_array($subArray);
} else {
$this->data['payrecipient_nondup'][] = iterator_to_array($subArray);
}
}
Run Code Online (Sandbox Code Playgroud)
这使我能够搜索数组并将其分成重复组和不重复组。
但是我不知道从哪里开始更新数组,所以我迷路了并被卡住了。