当前位置: 首页>>代码示例>>PHP>>正文


PHP Manufacturer::getInstanceById方法代码示例

本文整理汇总了PHP中Manufacturer::getInstanceById方法的典型用法代码示例。如果您正苦于以下问题:PHP Manufacturer::getInstanceById方法的具体用法?PHP Manufacturer::getInstanceById怎么用?PHP Manufacturer::getInstanceById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Manufacturer的用法示例。


在下文中一共展示了Manufacturer::getInstanceById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNextProduct

 public function getNextProduct()
 {
     if (!$this->productSql) {
         foreach ($this->languages as $code => $id) {
             list($join[], $langs[]) = $this->joinProductFields($id, $code);
         }
         foreach ($this->attributes as $attr) {
             $join[] = 'LEFT JOIN ' . $this->getTablePrefix() . 'extra_field_values  AS extra_' . $attr['fieldid'] . ' ON (extra_' . $attr['fieldid'] . '.productid=' . $this->getTablePrefix() . 'products.productid AND extra_' . $attr['fieldid'] . '.fieldid=' . $attr['fieldid'] . ')';
             $langs[] = 'extra_' . $attr['fieldid'] . '.value AS extrafield_' . $attr['fieldid'];
         }
         $this->productSql = 'SELECT ' . $this->getTablePrefix() . 'products.*, ' . $this->getTablePrefix() . 'products_categories.categoryid ' . ($langs ? ',' : '') . implode(', ', $langs) . ', (SELECT price FROM ' . $this->getTablePrefix() . 'pricing WHERE ' . $this->getTablePrefix() . 'pricing.productid=' . $this->getTablePrefix() . 'products.productid ORDER BY quantity ASC LIMIT 1) AS price FROM ' . $this->getTablePrefix() . 'products ' . implode(' ', $join) . ' LEFT JOIN ' . $this->getTablePrefix() . 'products_categories ON (' . $this->getTablePrefix() . 'products.productid=' . $this->getTablePrefix() . 'products_categories.productid AND ' . $this->getTablePrefix() . 'products_categories.main="Y")';
     }
     if (!($data = $this->loadRecord($this->productSql))) {
         return null;
     }
     $rec = Product::getNewInstance(Category::getInstanceById($this->getRealId('Category', $data['categoryid'])));
     $rec->setID($data['productid']);
     $rec->keywords->set($data['keywords']);
     $rec->setValueByLang('name', $this->defLang, $data['product']);
     $rec->setValueByLang('longDescription', $this->defLang, $data['fulldescr']);
     $rec->setValueByLang('shortDescription', $this->defLang, $data['descr']);
     foreach ($this->languages as $code => $id) {
         $rec->setValueByLang('name', $code, $data['name_' . $code]);
         $rec->setValueByLang('longDescription', $code, $data['fulldescr_' . $code]);
         $rec->setValueByLang('shortDescription', $code, $data['descr_' . $code]);
     }
     foreach ($this->attributes as $attr) {
         if (!empty($data['extrafield_' . $attr['fieldid']])) {
             $rec->setAttributeValueByLang(SpecField::getInstanceByID($this->getRealId('SpecField', $attr['fieldid']), SpecField::LOAD_DATA), $this->defLang, $data['extrafield_' . $attr['fieldid']]);
         }
     }
     if ($data['manufacturerid']) {
         $rec->manufacturer->set(Manufacturer::getInstanceById($this->getRealId('Manufacturer', $data['manufacturerid'])));
     }
     foreach (array('sku' => 'productcode', 'shippingWeight' => 'weight', 'stockCount' => 'avail', 'shippingSurchargeAmount' => 'shipping_freight', 'minimumQuantity' => 'min_amount', 'dateCreated' => 'add_date') as $lc => $xc) {
         $rec->{$lc}->set($data[$xc]);
     }
     $rec->isEnabled->set('Y' == $data['forsale']);
     $rec->setPrice($this->getDefaultCurrency(), $data['price']);
     //images
     $images = array_merge($this->getDataBySQL('SELECT * FROM ' . $this->getTablePrefix() . 'images_t WHERE id=' . $data['productid'] . ' ORDER BY orderby ASC'), $this->getDataBySQL('SELECT * FROM ' . $this->getTablePrefix() . 'images_d WHERE id=' . $data['productid'] . ' ORDER BY orderby ASC'));
     foreach ($images as $image) {
         $this->importProductImage($rec, $this->path . '/' . $image['image_path']);
     }
     $rec->rawData = $data;
     return $rec;
 }
开发者ID:saiber,项目名称:livecart,代码行数:47,代码来源:XCartImport.php

示例2: getNextProduct

 public function getNextProduct()
 {
     if (!$this->productSql) {
         foreach ($this->languages as $id => $code) {
             list($join[], $langs[]) = $this->joinProductFields($id, $code);
         }
         $this->productSql = 'SELECT *,' . implode(', ', $langs) . ' FROM ' . $this->getTablePrefix() . 'products ' . implode(' ', $join) . ' LEFT JOIN ' . $this->getTablePrefix() . 'products_to_categories ON ' . $this->getTablePrefix() . 'products.products_id=' . $this->getTablePrefix() . 'products_to_categories.products_id LEFT JOIN ' . $this->getTablePrefix() . 'categories ON ' . $this->getTablePrefix() . 'products_to_categories.categories_id=' . $this->getTablePrefix() . 'categories.categories_id  WHERE ' . $this->getTablePrefix() . 'categories.categories_id IS NOT NULL GROUP BY ' . $this->getTablePrefix() . 'products.products_id';
     }
     if (!($data = $this->loadRecord($this->productSql))) {
         return null;
     }
     $rec = Product::getNewInstance(Category::getInstanceById($this->getRealId('Category', $data['categories_id'])));
     $rec->setID($data['products_id']);
     foreach ($this->languages as $code) {
         $rec->setValueByLang('name', $code, $data['name_' . $code]);
         $rec->setValueByLang('longDescription', $code, $data['descr_' . $code]);
         // use the first line or paragraph of the long description as the short description
         $short = array_shift(preg_split("/\n|\\<br/", $data['descr_' . $code]));
         $rec->setValueByLang('shortDescription', $code, $short);
     }
     if ($data['manufacturers_id']) {
         try {
             $man = Manufacturer::getInstanceById($this->getRealId('Manufacturer', $data['manufacturers_id']), true);
             $man->load();
             $rec->manufacturer->set($man);
         } catch (Exception $e) {
             // orphan data
         }
     }
     $rec->sku->set($data['products_model']);
     $rec->URL->set($data['products_url']);
     $rec->isEnabled->set((int) (1 == $data['products_status']));
     $rec->shippingWeight->set($data['products_weight']);
     $rec->stockCount->set($data['products_quantity']);
     $rec->dateCreated->set($data['products_date_added']);
     $rec->setPrice($this->getConfigValue('DEFAULT_CURRENCY'), $data['products_price']);
     //product image
     if ($data['products_image']) {
         $this->importProductImage($rec, $this->path . '/images/' . $data['products_image']);
     }
     $rec->rawData = $data;
     return $rec;
 }
开发者ID:saiber,项目名称:livecart,代码行数:43,代码来源:OsCommerceImport.php


注:本文中的Manufacturer::getInstanceById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。