public function importOnlySimpleProduct() { $read= Mage::getSingleton('core/resource')->getConnection('core_read'); $sql = "SELECT `mid` AS `product_id` FROM `old_data_import` WHERE NOT `mid` IN (SELECT `product_id` FROM `old_product_option_value` GROUP BY `product_id`) AND `type` = 3 AND NOT `html` IS NULL GROUP BY `mid` ";//不在option表里的商品id $model=Mage::getModel('eav/entity_setup','core_setup'); $results = $read->query($sql); foreach ($results as $key=>$row) { $product_id = $row['product_id']; $sql = "select * from `old_data_import` WHERE `mid` = ? and not `html` is null and type = 3 limit 1"; $product_result = $read->query($sql,array($product_id)); foreach ($product_result as $row_p) { //get product name $html = new simple_html_dom(); $html->load($row_p['html']); $ret = $html->find('h1.productTitle'); $product_name = ''; if (count($ret)) { foreach ($ret as $e) { $product_name = trim($e->innertext); break; } } var_dump('name:' . $product_name); //get product categories $cateids = $this->getCategoryIds($product_id); //get product shortdescription $ret_short_desc = $html->find('span.productShortDescription'); $product_short_desc = ''; if (count($ret_short_desc)) { foreach ($ret_short_desc as $e_short_desc) { $product_short_desc= trim($e_short_desc->innertext); break; } } var_dump('Short Desc:' . $product_short_desc); //get product description $ret_desc = $html->find('div.productLongDescription'); $product_desc = ''; if (count($ret_desc)) { foreach ($ret_desc as $e_desc) { $product_desc= trim($e_desc->innertext); break; } } var_dump('Desc:' . $product_desc); //get product price $product_price = 0; $sql_price = "select price from old_data_price where product_id=? limit 1"; $results_price = $read->query($sql_price,array($row_p['mid'])); foreach ($results_price as $data_price) { $product_price = (float)$data_price['price']; } var_dump('Price:' . $product_price); // Create the Magento product model $sProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',trim((int)$row_p['mid'])); if (!$sProduct) { $sProduct = Mage::getModel('catalog/product'); $sProduct ->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) ->setWebsiteIds(array(1)) ->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) ->setAttributeSetId(4) ->setCategoryIds($cateids) // Populated further up the script ->setSku(trim((int)$row_p['mid'])) // $main_product_data is an array created as part of a wider foreach loop, which this code is inside of ->setName($product_name) ->setDescription($product_desc) ->setShortDescription($product_short_desc) ->setPrice(sprintf("%0.2f", $product_price)) ; // Set the stock data. Let Magento handle this as opposed to manually creating a cataloginventory/stock_item model.. $sProduct->setStockData(array( 'is_in_stock' =>1, 'qty' => 99999 )); $sProduct->save(); var_dump($sProduct->getSku() . ' import success'); //import product images //get images; $ret_main_images = $html->find('a.MagicZoom'); $images = array(); if (count($ret_main_images)) { foreach ($ret_main_images as $main_e) { $images[]=trim($main_e->href); } } //get additionnal images $ret_add_images = $html->find('div.productAdditionalImages div.productAdditionalImage img'); if (count($ret_add_images)) { foreach ($ret_add_images as $add_e) { $images[] = trim($add_e->src); } } //默认第一张是主图。作为各种默认图片,后面的追加。 $this->importProductImages($images,trim((int)$row_p['mid'])); var_dump($sProduct->getSku(). ' images import success'); } break; } } }
相关推荐
BigBridge产品导入 你好! 我叫帕特里克·范·卑尔根。 我创建此库是因为我需要快速导入产品。 该库通过直接数据库查询将产品数据导入到Magento 2中。 它具有这些主要特征 ... $product = new Simple
本项目"simple_ecommerce"是一个基于Django构建的电子商务网站,具备基础的购物车、商品展示以及支付集成功能。下面将详细探讨该项目中的关键知识点。 ### 1. Django框架基础 Django遵循MTV(Model-Template-View...
- **JOB_NAME:** 为本次导入任务命名,如 `Import_Simple`。 - **STREAMS_CONFIGURATION:** 设置为 `n`。 - **TABLE_EXISTS_ACTION:** 如果表已经存在,则选择 `SKIP` 行动。 - **CONTENT:** 选择 **ALL** 导入...
kbuilder.add(ResourceFactory.newClassPathResource("simple.rule"), ResourceType.DRL); // 检查构建错误 if (kbuilder.hasErrors()) { System.err.println(kbuilder.getErrors().toString()); return; } ...
Amenities: Convenient, simple and intuitive user interface, and an open XML-architecture solutions 3DVia Composer allows a wide range of users with no technical skills to develop technical ...
•Numerous product constellations to meet your requirements: VAR, Site, Starter Pack, Single User License, free Personal and Educational versions. •All registered versions include a full set of the ...
import Carousel from 'ui-carousel' ; const ProductsSlider = props => { const { product , refresh } = props ; // refresh true or false // start from activeSlide position, // you can create ...
XLSReadWriteII is a simple solution for working with Excel files in Delphi. Delphi programmers can easily access Excel files with this library and perform their processing on these files. For the ...
dot_product = vec.dot(mathutils.Vector((4, 5, 6))) ``` ##### 2.2 字体绘制 (blf) - **定义**:`blf` 提供了字体绘制的功能。 - **作用**:可以在Blender中绘制文本。 - **示例代码**: ```python import ...
public class SimpleFactory { public Product createProduct(char type) { switch (type) { case 'A': return new ConcreteProductA(); case 'B': return new ConcreteProductB(); default: return null; ...
主页: : 文档: : 资料来源: : 错误: : product ##通过GObject自省使用。 由于GSound基于libcanberra,因此它共享类似的API。 要使用它,首先要创建并初始化GSound上下文。 然后,您向上下文传递(属性,值)对...
它巧妙地融合了深度学习的目标检测能力和SORT(Simple Online and Realtime Tracking)算法的跟踪机制,尤其适用于处理视频监控、自动驾驶等领域的多目标跟踪任务。通过深度学习的目标检测器获取每一帧的目标信息,...
The guide acknowledges and recognizes the trademarks of product names mentioned within the manual, emphasizing the respect for intellectual property rights. This includes acknowledging the registered ...
Product Specific Operating System-Specific Accuracy of Messages Message Format Recognizing Variable Text in Messages Message Stacks Contacting Oracle Support Services Oracle Exception Messages Trace ...
2. **SORT跟踪器**:SORT(Simple Online and Realtime Tracking)算法被用于跟踪视频中的多个目标。在DeepSORT中,SORT跟踪器被改进,加入了深度学习特征,使得在计算匹配代价时更加精确,从而提高了跟踪的准确性。...
在这个例子中,`simple_generator`是一个生成器函数,它使用`yield`语句返回一系列数字。 #### 四、Map,Filter和Reduce 这三个函数是Python标准库中的高级函数,用于对列表或其他可迭代对象进行转换和聚合操作。 ...
from woocommerce import WC wc = WC({ 'url': 'https://your-woo-commerce-site.com', 'consumer_key': 'your-consumer-key', 'consumer_secret': 'your-consumer-secret' }) new_product = { "name": ...
Some of these files are complete applications, games, or other types of content, while others are simple movies which are intended to introduce a concept that you can use to build your own movies....
SQLMemTable provides you with the simplest way to import and export tables using ImportTable and ExportTable methods. - Internationalization / localization support. All text search and sorting ...