本文整理汇总了PHP中Product::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::setName方法的具体用法?PHP Product::setName怎么用?PHP Product::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOrderByOrderTime
public function getOrderByOrderTime($campaignId, $orderStatTime, $orderEndTime)
{
if (empty($campaignId) || empty($orderStatTime) || empty($orderEndTime)) {
echo "campaignId ,orderStatTime or orderEndTime is null";
exit;
}
$sql = "SELECT p.order_id,order_sn,add_time,order_status,pay_status,pay_name,order_time,cid,wi,order_status,pay_status,pay_name,shipping_fee,surplus,bonus,order_amount FROM `cps` as p LEFT OUTER JOIN ecs_order_info as i on i.order_id=p.order_id where p.cid=" . $campaignId . " and order_time>" . $orderStatTime . " and order_time<" . $orderEndTime;
$dborder = $GLOBALS['db']->getAll($sql);
if (empty($dborder)) {
return NULL;
}
foreach ($dborder as $k => $v) {
$order = new Order();
$order->setOrderNo($v['order_sn']);
$order_time = date('Y-m-d H:i:s', $v['order_time']);
$order->setOrderTime($order_time);
// 设置下单时间
$order->setUpdateTime($order_time);
// 设置订单更新时间,如果没有下单时间,要提前对接人提前说明
$order->setCampaignId($v['cid']);
// 测试时使用"101",正式上线之后活动id必须要从数据库里面取
$order->setFeedback($v['wi']);
$order->setFare($v['shipping_fee']);
$order->setFavorable($v['bonus'] + $v['surplus']);
//$orderStatus = new OrderStatus();
//$orderStatus -> setOrderNo($order -> getOrderNo());
$order->setOrderStatus($v['order_status']);
// 设置订单状态
$order->setPaymentStatus($v['pay_status']);
// 设置支付状态
$order->setPaymentType($v['pay_name']);
// 支付方式
$sql = "select * from ecs_order_goods where order_id=" . $v['order_id'] . " and goods_price>100";
$order_goods = $GLOBALS['db']->getAll($sql);
//echo "<pre>";print_r($order_goods);
foreach ($order_goods as $k1 => $v1) {
$pro = new Product();
//$pro -> setOrderNo($order -> getOrderNo());
$pro->setProductNo($v1['goods_sn']);
$pro->setName($v1['goods_name']);
$pro->setCategory("蛋糕");
$pro->setCommissionType("");
$pro->setAmount($v1['goods_number']);
$a = number_format($v1['goods_price'] * (1 - ($v['bonus'] + $v['surplus']) / ($v['bonus'] + $v['surplus'] + $v['order_amount'])), 2, ".", "");
$pro->setPrice($a);
$products[] = $pro;
}
$order->setProducts($products);
$orderlist[] = $order;
$products = array();
}
//print_r($orderlist);
//echo json_encode($orderlist);
return $orderlist;
}
示例2: getProduct
public function getProduct($product_id)
{
$db = Database::getDB();
$query = "SELECT * FROM products\n WHERE productID = '{$product_id}'";
$result = $db->query($query);
$row = $result->fetch();
$category = CategoryDB::getCategory($row['categoryID']);
$product = new Product();
$product->setCategory($category);
$product->setId($row['productID']);
$product->setCode($row['productCode']);
$product->setName($row['productName']);
$product->setPrice($row['listPrice']);
return $product;
}
示例3: getProductBySku
function getProductBySku($sku)
{
global $database, $logger;
$logger->debug(get_class($this) . "::getProductBySku({$sku})");
$prod = new Product();
$ps_prod = new ps_product();
$ps_cat = new ps_product_category();
$query = "select product_id from #__vm_product where product_sku=" . $sku;
$database->loadQuery($query);
$id = $db->loadResult();
$prod->setOid($id);
$prod->setName($ps_prod->get_field('product_name'));
$prod->setFlypage($ps_prod->get_flypage($id));
$prod->setCategoryId($ps_cat->get_cid($id));
return $prod;
}
示例4: createAction
public function createAction()
{
$view = new ViewModel();
$request = $this->getRequest();
if ($request->isPost()) {
$entityManager = $this->getEntityManager();
$strProduct = $request->getPost()->product;
$product = new \Product();
$product->setName($strProduct);
$entityManager->persist($product);
$entityManager->flush();
$view->setVariable('product', $product);
$view->setTemplate('application/product/create_post');
}
return $view;
}
示例5: test_create_and_retrieve
public function test_create_and_retrieve()
{
global $entityManager;
$product = new Product();
$product->setName('test product 1');
$entityManager->persist($product);
$entityManager->flush();
$id = $product->getId();
$this->assertFirstGreaterThanSecond($id, 0);
/** @var Product $product */
$product = $entityManager->find('Product', $id);
$this->assertEqual($product->getId(), $id);
$this->assertEqual($product->getName(), 'test product 1');
$this->assertEqual(strlen($product->getCreated()), 19, 'created');
$this->assertEqual(strlen($product->getUpdated()), 19, 'updated');
}
示例6: generateProducts
public static function generateProducts()
{
//read in xml document(products)
$doc = simplexml_load_file(APPLICATION_PATH . '/../products.xml');
foreach ($doc->category as $cat) {
$categoryObj = new Category();
$categoryObj->setUrlKey($cat->urlkey);
$categoryObj->setName($cat->name);
$categoryObj->save();
}
foreach ($doc->product as $product) {
$productObj = new Product();
$productObj->setName($product->name);
$productObj->setPrice($product->price);
$productObj->setSku($product->sku);
$productObj->setDateCreated(date('d-m-Y H:i:s', time()));
$productObj->setUrlKey($product->urlkey);
$productObj->setProductImage($product->image);
$productObj->setCategoryId($product->category);
$productObj->save();
}
}
示例7: create
public function create(SubCategory $sub_category, $name, $description, $price, $img, $stock)
{
$errors = array();
$product = new Product($this->db);
try {
$product->setSubCategory($sub_category);
$product->setName($name);
$product->setDescription($description);
$product->setPrice($price);
$product->setImg($img);
$product->setStock($stock);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
$errors = array_filter($errors, function ($val) {
return $val !== true;
});
if (count($errors) == 0) {
$idSubCategory = intval($product->getIdSubCategory());
$name = $this->db->quote($product->getName());
$description = $this->db->quote($product->getDescription());
$price = $this->db->quote($product->getPrice());
$img = $this->db->quote($product->getImg());
$stock = $this->db->quote($product->getStock());
$query = "INSERT INTO product(id_sub_category, name, description, price, img, stock) VALUES('" . $idSub_category . "', " . $name . ", " . $description . ", " . $price . ", " . $img . ", " . $stock . ")";
$res = $this->db->exec($query);
if ($res) {
$id = $this->db->lastInsertId();
if ($id) {
return $this->findById($id);
} else {
return "Internal Server error";
}
}
} else {
return $errors;
}
}
示例8: foreach
// 测试时使用"101",正式上线之后活动id必须要从cookie中获取
$cps->setFare($order['shipping_fee']);
$cps->setFavorable($order['bonus'] + $order['surplus']);
// 设置优惠券
$cps->setOrderStatus($order['order_status']);
// 设置订单状态
$cps->setPaymentStatus($order['pay_status']);
// 设置支付状态
$cps->setPaymentType($order['pay_name']);
// 支付方式
foreach ($cart_goods as $k => $v) {
if ($v['goods_price'] > 0) {
$pro = new Product();
// $pro2 -> setOrderNo($order -> getOrderNo());
$pro->setProductNo($v['goods_sn']);
$pro->setName($v['goods_name']);
$pro->setCategory("蛋糕");
$pro->setCommissionType("");
$pro->setAmount($v['goods_number']);
$a = number_format($v['goods_price'] * (1 - ($order['bonus'] + $order['surplus']) / ($order['bonus'] + $order['surplus'] + $order['order_amount'])), 2, ".", "");
$pro->setPrice($a);
$products[] = $pro;
}
}
$cps->setProducts($products);
//var_dump(get_object_vars($cps));
$sender = new Sender();
$sender->setOrder($cps);
$sender->sendOrder();
$ordertime = $order['add_time'] + 8 * 3600;
$sql = "INSERT INTO cps ( " . "order_id,src,channel,cid,wi,order_time)" . " values('{$new_order_id}','emar','cps'," . $arr[2] . ",'" . $arr[3] . "','" . $ordertime . "') ";
示例9: catch
} catch (Exception $e) {
error('io-error', $e->getMessage());
}
});
});
/*
* create new product
*/
$app->post('/products', function () use($app) {
disable_cache($app);
// only admins can create products
if_is_admin(function () use($app) {
try {
$params = json_decode($app->request()->getBody(), true);
$product = new Product();
$product->setName($params['name']);
$product->setCreatedAt(time());
if (isset($params['data'])) {
$product->setData(json_encode($params['data']));
}
$product->save();
ok($product->toArray());
} catch (Exception $e) {
error('io-error', $e->getMessage());
}
});
});
/*
* change product
*/
$app->put('/products/:id', function ($id) use($app) {
示例10: Product
<?php
include __DIR__ . '/bootstrap.php';
include __DIR__ . '/../../bootstrap.php';
$debugbarRenderer->setBaseUrl('../../../src/DebugBar/Resources');
$debugStack = new Doctrine\DBAL\Logging\DebugStack();
$entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
$debugbar->addCollector(new DebugBar\Bridge\DoctrineCollector($debugStack));
$product = new Product();
$product->setName("foobar");
$entityManager->persist($product);
$entityManager->flush();
render_demo_page();
示例11: testShouldThrowsAnExceptionWhenSettingAnInvalidArgument
/**
* @expectedException InvalidArgumentException
*/
public function testShouldThrowsAnExceptionWhenSettingAnInvalidArgument()
{
$instance = new Product();
$instance->setName(1);
}
示例12: testName
public function testName()
{
$this->assertSame($this->entity, $this->entity->setName('Foo'));
$this->assertSame('Foo', $this->entity->getName());
$this->assertSame('Foo', $this->entity->__toString());
}
示例13: importProducts
public function importProducts(Import $entity, $output)
{
$sql = ' SELECT p.*, o.nombre as opticName, m.nombre as brand, mo.nombre as model, s.nombre as category FROM `producto` AS p ' . ' LEFT JOIN optica AS o ON o.id = p.id_optica ' . ' LEFT JOIN servicio AS s ON s.id = p.id_servicio ' . ' LEFT JOIN marca AS m ON m.id_marca = p.id_marca ' . ' LEFT JOIN modelo AS mo ON mo.id_modelo = p.id_modelo ' . ' ORDER BY p.id ' . ' LIMIT ' . $entity->getLimitStart() . ', ' . $entity->getLimitEnd();
$link = mysqli_connect($entity->getServer(), $entity->getUsername(), $entity->getPassword(), $entity->getDbname()) or die('No se pudo conectar: ' . mysqli_error($link));
$resultado = $link->query($sql);
$x = 0;
if (mysqli_num_rows($resultado) > 0) {
while ($fila = mysqli_fetch_assoc($resultado)) {
$x++;
print_r($x . '-' . utf8_encode($fila['nombre']));
echo PHP_EOL;
$em = $this->container->get('doctrine')->getManager();
$optic = $em->getRepository('CoreBundle:Optic')->findOneByName(utf8_encode($fila['opticName']));
$category = $em->getRepository('EcommerceBundle:Category')->findOneByName(utf8_encode($fila['category']));
$brand = $em->getRepository('EcommerceBundle:Brand')->findOneByName(utf8_encode($fila['brand']));
$model = $em->getRepository('EcommerceBundle:BrandModel')->findOneByName(utf8_encode($fila['model']));
//Create Products
if ($optic instanceof Optic && $fila['id'] != 746 && $fila['id'] != 747 && $fila['id'] != 748 && $fila['id'] != 749 && $fila['id'] != 750 && $fila['id'] != 751 && $fila['id'] != 752 && $fila['id'] != 753) {
$product = new Product();
$product->setName(utf8_encode($fila['nombre']));
$product->setDescription(utf8_encode($fila['descripcion']));
if ($fila['precio_original'] != '') {
$product->setInitPrice($fila['precio_original']);
} else {
$product->setInitPrice(0);
}
$product->setPrice($fila['precio']);
if ($fila['tipo_precio'] != '') {
$product->setPriceType($fila['tipo_precio']);
} else {
$product->setPriceType(0);
}
$product->setDiscount($fila['descuento']);
$product->setDiscountType($fila['tipo_descuento']);
if ($fila['stock'] != '') {
$product->setStock($fila['stock']);
} else {
$product->setStock(0);
}
$product->setWeight($fila['kilos']);
$product->setOutlet($fila['outlet']);
$product->setPublic($fila['publicado']);
if ($fila['recoger_tienda'] != '') {
$product->setStorePickup($fila['recoger_tienda']);
} else {
$product->setStorePickup(0);
}
$product->setMetaTitle(utf8_encode($fila['meta_titulo']));
$product->setMetaDescription(utf8_encode($fila['meta_descripcion']));
$product->setMetaTags(utf8_encode($fila['meta_keywords']));
$product->setOptic($optic);
$product->setBrand($brand);
$product->setModel($model);
$product->setCategory($category);
$product->setActive(true);
$product->setAvailable(true);
$product->setHighlighted(false);
$product->setFreeTransport(false);
$slug = $this->slugify(utf8_encode($fila['nombre'] . '-' . $optic->getCity()));
// $p = $em->getRepository('EcommerceBundle:Product')->findOneBySlug($slug);
// if($p instanceof Product) $slug = $slug.'_'.rand(1000,9999);
$product->setSlug($slug);
$em->persist($product);
$em->flush();
//image
if ($fila['imagen'] != '') {
$imagePath = '';
$dir = '/home/sebastian/www/src/Symfony/web/uploads/documents';
$absoluteImagePath = $dir . '/' . utf8_encode($fila['imagen']);
if (file_exists($absoluteImagePath . '.jpeg')) {
$imagePath = utf8_encode($fila['imagen']) . '.jpeg';
}
if (file_exists($absoluteImagePath . '.jpg')) {
$imagePath = utf8_encode($fila['imagen']) . '.jpg';
}
if (file_exists($absoluteImagePath . '.gif')) {
$imagePath = utf8_encode($fila['imagen']) . '.gif';
}
if (file_exists($absoluteImagePath . '.png')) {
$imagePath = utf8_encode($fila['imagen']) . '.png';
}
//Thumb
$imagePathThumb = '';
$absoluteImagePathThumb = $dir . '/' . utf8_encode($fila['imagen']) . '_260.jpg';
if (file_exists($absoluteImagePathThumb)) {
$imagePathThumb = utf8_encode($fila['imagen']) . '_260.jpg';
}
$imagePathThumb2 = '';
$absoluteImagePathThumb2 = $dir . '/' . utf8_encode($fila['imagen']) . '_142.jpg';
if (file_exists($absoluteImagePathThumb2)) {
$imagePathThumb2 = utf8_encode($fila['imagen']) . '_142.jpg';
}
if ($imagePath == '') {
$dir = 'http://web.com/uploads/documents/';
$imagePath = $fila['imagen'] . '.' . $fila['extension_img'];
}
print_r($dir . '/' . $imagePath);
echo PHP_EOL;
@mkdir(__DIR__ . '/../../../../../web/uploads/images/product');
@mkdir(__DIR__ . '/../../../../../web/uploads/images/product/' . $product->getId());
//.........这里部分代码省略.........
示例14: Product
$pro->setCategory("asdf");
// 设置商品类型
$pro->setCommissionType("A");
// 设置佣金类型,如:普通商品 佣金比例是10%、佣金编号(可自行定义然后通知双方商务)A
$pro->setAmount("1");
// 设置商品数量
$pro->setPrice("3000");
// 设置商品价格
$pro1 = new Product();
// $pro1 -> setOrderNo($order -> getOrderNo());
$pro1->setProductNo("1002");
$pro1->setName("测试商品5");
$pro1->setCategory("a");
$pro1->setCommissionType("B");
$pro1->setAmount("3");
$pro1->setPrice("100");
$pro2 = new Product();
// $pro2 -> setOrderNo($order -> getOrderNo());
$pro2->setProductNo("1003");
$pro2->setName("测试商品4");
$pro2->setCategory("2");
$pro2->setCommissionType("B");
$pro2->setAmount("5");
$pro2->setPrice("500");
$products = array($pro, $pro1, $pro2);
// 实现商品信息集合
$order->setProducts($products);
//var_dump(get_object_vars($order));
$sender = new Sender();
$sender->setOrder($order);
$sender->sendOrder();
示例15: setName
public function setName($name)
{
$this->__load();
return parent::setName($name);
}