0
A
回答
0
我已经在我的自定义magneto API中创建了这个功能。它将生成带有选定产品列的sqlite数据库。您可以将它与您的magento一起使用并据此设置路径。 我很高兴在这里分享。如果您可以改进或想用我的代码向我推荐,那么欢迎您。
感谢所有提前。
/* **功能来创建产品的SQLite数据库 * */
public function sqlitedb()
{
$root= dirname(Mage::getRoot());
$path=$root.'/marcodeappdb';
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
unlink($path.'/marcodeapp.zip');
$database = new sqlite3($path.'/marcodeapp.sqlite');
$query = 'CREATE TABLE Products '.'(Sku TEXT, Name TEXT, Price INTEGER,ShortD TEXT,Description TEXT,Image TEXT,Categories TEXT)';
$database->exec($query);
$collection=Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToSelect('*');
//pr($collection);
foreach($collection as $product){
$sku=$product->sku;
$name=$product->getName();
$price=$product->getPrice();
$shortd=$product->getDescription();
$description=$product->getDescription();
$image=$product->getImageUrl();
//categoryids
$catids=$product->getCategoryIds();
$productcatname=array();
foreach($catids as $catid){
$category = Mage::getModel('catalog/category')->load($catid);
$productcatname[]=$category->getName();
}
$productcate=implode(',',$productcatname);
$query ="INSERT INTO Products (Sku, Name, Price,ShortD,Description,Image,Categories) VALUES ('$sku', '$name', '$price','$shortd','$description','$image','$productcate');";
$database->exec($query);
unset($query);
unset($sku);
unset($name);unset($price);unset($shortd);unset($description);unset($image);
unset($productcate);unset($productcatname);
}
$database->close();
$files_to_zip = array($path.'/marcodeapp.sqlite');
$result = $this->create_zip($files_to_zip,$path.'/marcodeapp.zip');
unlink($path.'/marcodeapp.sqlite');
return 'http://mercode.com.br/MERCODE/marcodeappdb/marcodeapp.zip';
}
相关问题
- 1. 如何通过Magento API创建可下载的产品?
- 2. 如何为magento可下载产品创建发票?
- 3. WSO2:如何在Dockerfile中下载产品?
- 4. 如何在magento中创建产品的价格格式
- 5. 如何下载新的Spring产品?
- 6. MySQL排名产品下载
- 7. Bigcommerce api创建产品
- 8. 可下载的产品链接在1.9.2
- 9. Magento以可编程的方式通过可下载的产品创建订单
- 10. 以编程方式创建可下载的产品,显示缺货
- 11. 如何为以下产品形成创建for/while循环?
- 12. 无法使用web-api在Dynamics CRM中的报价下创建写入产品
- 13. 以AEM原始格式下载资产
- 14. Magento:跟踪可下载产品链接的下载量
- 15. Woocommerce定制下载的产品类型
- 16. Magento的 - 购买可下载产品
- 17. Magento中的可下载产品
- 18. Magento - 如何根据产品选择加载下面的一组产品?
- 19. 如何在生产模式下创建应用程序Ionic3?
- 20. 创建产品
- 21. 如何在网格下创建按钮?
- 22. 如何创建产品表,其中每个产品在MySQL中的多个类别下?
- 23. 如何通过REST API在Magento 2中创建包产品?
- 24. 如何使用Ruby在Magento Api上创建产品图像
- 25. Google Drive API创建和下载PDF
- 26. 产品创建不起作用(在Spring MVC下使用JPA)
- 27. 下拉式产品,将价格放在文本字段中
- 28. 下载Magento Frontpage显示所有产品
- 29. 单个产品下载链接
- 30. [Android]产品下载YouTube视频