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


PHP Product::updateDefaultAttribute方法代码示例

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


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

示例1: update

 public function update($null_values = false)
 {
     if ($this->default_on) {
         $this->default_on = 1;
     } else {
         $this->default_on = null;
     }
     $return = parent::update($null_values);
     Product::updateDefaultAttribute($this->id_product);
     return $return;
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:11,代码来源:Combination.php

示例2: checkProductStock

 protected function checkProductStock($product, $id_order_state)
 {
     if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR')) {
         $update_quantity = true;
         $qty = PP::resolveQty($product['cart_quantity'], $product['cart_quantity_fractional']);
         if (!StockAvailable::dependsOnStock($product['id_product'])) {
             $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -$qty);
         }
         if ($update_quantity) {
             $product['stock_quantity'] -= $qty;
         }
         if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
             $this->outOfStock = true;
         }
         Product::updateDefaultAttribute($product['id_product']);
     }
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:17,代码来源:OrderDetail.php

示例3: checkProductStock

 /**
  * Check the order status
  * @param array $product
  * @param int $id_order_state
  */
 protected function checkProductStock($product, $id_order_state)
 {
     $this->outOfStock = false;
     return;
     //TODO
     if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR')) {
         $update_quantity = false;
         if (!StockAvailable::dependsOnStock($product['id_product'])) {
             $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int) $product['cart_quantity']);
         }
         if ($update_quantity) {
             $product['stock_quantity'] -= $product['cart_quantity'];
         }
         if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
             $this->outOfStock = true;
         }
         Product::updateDefaultAttribute($product['id_product']);
     }
 }
开发者ID:paolobattistella,项目名称:aphro,代码行数:24,代码来源:AphOrderDetail.php

示例4: attributeImportOne


//.........这里部分代码省略.........
                                    // FIXME: ~3s/declinaison
                                    $product->updateAttribute($id_product_attribute, (double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, $id_image, strval($info['reference']), strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $info['available_date'], null, $id_shop_list);
                                    $id_product_attribute_update = true;
                                    if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) {
                                        $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
                                    }
                                    // until here
                                }
                            }
                        }
                    }
                    // if no attribute reference is specified, creates a new one
                    if (!$id_product_attribute && !$validateOnly) {
                        $id_product_attribute = $product->addCombinationEntity((double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, (int) $info['quantity'], $id_image, strval($info['reference']), 0, strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $id_shop_list, $info['available_date']);
                        if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) {
                            $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']);
                        }
                    }
                    // fills our attributes array, in order to add the attributes to the product_attribute afterwards
                    if (isset($attributes[$group . '_' . $attribute])) {
                        $attributes_to_add[] = (int) $attributes[$group . '_' . $attribute];
                    }
                    // after insertion, we clean attribute position and group attribute position
                    if (!$validateOnly) {
                        $obj = new Attribute();
                        $obj->cleanPositions((int) $id_attribute_group, false);
                        AttributeGroup::cleanPositions();
                    }
                }
            }
        }
        $product->checkDefaultAttributes();
        if (!$product->cache_default_attribute && !$validateOnly) {
            Product::updateDefaultAttribute($product->id);
        }
        if ($id_product_attribute) {
            if (!$validateOnly) {
                // now adds the attributes in the attribute_combination table
                if ($id_product_attribute_update) {
                    Db::getInstance()->execute('
						DELETE FROM ' . _DB_PREFIX_ . 'product_attribute_combination
						WHERE id_product_attribute = ' . (int) $id_product_attribute);
                }
                foreach ($attributes_to_add as $attribute_to_add) {
                    Db::getInstance()->execute('
						INSERT IGNORE INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute)
						VALUES (' . (int) $attribute_to_add . ',' . (int) $id_product_attribute . ')', false);
                }
            }
            // set advanced stock managment
            if (isset($info['advanced_stock_management'])) {
                if ($info['advanced_stock_management'] != 1 && $info['advanced_stock_management'] != 0) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management has incorrect value. Not set for product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id);
                } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $info['advanced_stock_management'] == 1) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot enable on product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id);
                } elseif (!$validateOnly) {
                    $product->setAdvancedStockManagement($info['advanced_stock_management']);
                }
                // automaticly disable depends on stock, if a_s_m set to disabled
                if (!$validateOnly && StockAvailable::dependsOnStock($product->id) == 1 && $info['advanced_stock_management'] == 0) {
                    StockAvailable::setProductDependsOnStock($product->id, 0, null, $id_product_attribute);
                }
            }
            // Check if warehouse exists
            if (isset($info['warehouse']) && $info['warehouse']) {
                if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php

示例5: ajaxProcessDeleteProductAttribute

 public function ajaxProcessDeleteProductAttribute()
 {
     if (!Combination::isFeatureActive()) {
         return;
     }
     if ($this->tabAccess['delete'] === '1') {
         $id_product = (int) Tools::getValue('id_product');
         $id_product_attribute = (int) Tools::getValue('id_product_attribute');
         if ($id_product && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) {
             if (($depends_on_stock = StockAvailable::dependsOnStock($id_product)) && StockAvailable::getQuantityAvailableByProduct($id_product, $id_product_attribute)) {
                 $json = array('status' => 'error', 'message' => $this->l('It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.'));
             } else {
                 $product->deleteAttributeCombination((int) $id_product_attribute);
                 $product->checkDefaultAttributes();
                 Tools::clearColorListCache((int) $product->id);
                 if (!$product->hasAttributes()) {
                     $product->cache_default_attribute = 0;
                     $product->update();
                 } else {
                     Product::updateDefaultAttribute($id_product);
                 }
                 if ($depends_on_stock && !Stock::deleteStockByIds($id_product, $id_product_attribute)) {
                     $json = array('status' => 'error', 'message' => $this->l('Error while deleting the stock'));
                 } else {
                     $json = array('status' => 'ok', 'message' => $this->_conf[1], 'id_product_attribute' => (int) $id_product_attribute);
                 }
             }
         } else {
             $json = array('status' => 'error', 'message' => $this->l('You cannot delete this attribute.'));
         }
     } else {
         $json = array('status' => 'error', 'message' => $this->l('You do not have permission to delete this.'));
     }
     die(Tools::jsonEncode($json));
 }
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:35,代码来源:AdminProductsController.php

示例6: Product

             $product_price = new Product($id_product_old, false, null, $shop['id_shop']);
             $product->price = $product_price->price;
         }
     }
 }
 if (Validate::isLoadedObject($product)) {
     $id_product_old = $product->id;
     for ($i = 1; $i <= $quantity; $i++) {
         echo $i;
         unset($product->id);
         unset($product->id_product);
         $product->indexed = 0;
         $product->active = 0;
         if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) {
             if ($product->hasAttributes()) {
                 Product::updateDefaultAttribute($product->id);
             }
             if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) {
                 echo 'An error occurred while copying images.';
             } else {
                 Hook::exec('actionProductAdd', array('product' => $product));
                 if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
                     Search::indexation(false, $product->id);
                 }
                 echo ' Duplication, ProductAddHook and re-index done. ';
             }
         } else {
             echo 'An error occurred while duplicating some object properties.';
         }
     }
 }
开发者ID:EliosIT,项目名称:PS_AchatFilet,代码行数:31,代码来源:duplication.php

示例7: postProcess


//.........这里部分代码省略.........
                        }
                        if (Tools::strlen($attachment->file_name) > 128) {
                            $this->_errors[] = Tools::displayError('File name too long');
                        }
                        if (!sizeof($this->_errors)) {
                            $attachment->add();
                            Tools::redirectAdmin($currentIndex . '&id_product=' . (int) Tools::getValue($this->identifier) . '&id_category=' . (int) Tools::getValue('id_category') . '&addproduct&conf=4&tabs=6&token=' . ($token ? $token : $this->token));
                        } else {
                            $this->_errors[] = Tools::displayError('Invalid file');
                        }
                    }
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to add here.');
            }
        } elseif (Tools::isSubmit('submitAttachments')) {
            if ($this->tabAccess['edit'] === '1') {
                if ($id = (int) Tools::getValue($this->identifier)) {
                    if (Attachment::attachToProduct($id, $_POST['attachments'])) {
                        Tools::redirectAdmin($currentIndex . '&id_product=' . (int) $id . (isset($_POST['id_category']) ? '&id_category=' . (int) $_POST['id_category'] : '') . '&conf=4&add' . $this->table . '&tabs=6&token=' . ($token ? $token : $this->token));
                    }
                }
            }
        } elseif (isset($_GET['duplicate' . $this->table])) {
            if ($this->tabAccess['add'] === '1') {
                if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) {
                    $id_product_old = $product->id;
                    unset($product->id);
                    unset($product->id_product);
                    $product->indexed = 0;
                    $product->active = 0;
                    if ($product->add() and Category::duplicateProductCategories($id_product_old, $product->id) and ($combinationImages = Product::duplicateAttributes($id_product_old, $product->id)) !== false and GroupReduction::duplicateReduction($id_product_old, $product->id) and Product::duplicateAccessories($id_product_old, $product->id) and Product::duplicateFeatures($id_product_old, $product->id) and Product::duplicateSpecificPrices($id_product_old, $product->id) and Pack::duplicate($id_product_old, $product->id) and Product::duplicateCustomizationFields($id_product_old, $product->id) and Product::duplicateTags($id_product_old, $product->id) and Product::duplicateDownload($id_product_old, $product->id)) {
                        if ($product->hasAttributes()) {
                            Product::updateDefaultAttribute($product->id);
                        }
                        if (!Tools::getValue('noimage') and !Image::duplicateProductImages($id_product_old, $product->id, $combinationImages)) {
                            $this->_errors[] = Tools::displayError('An error occurred while copying images.');
                        } else {
                            Hook::addProduct($product);
                            Search::indexation(false, $product->id);
                            Tools::redirectAdmin($currentIndex . '&id_category=' . (!empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1') . '&conf=19&token=' . ($token ? $token : $this->token));
                        }
                    } else {
                        $this->_errors[] = Tools::displayError('An error occurred while creating object.');
                    }
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to add here.');
            }
        } elseif (isset($_GET['status']) and Tools::getValue($this->identifier)) {
            if ($this->tabAccess['edit'] === '1') {
                if (Validate::isLoadedObject($object = $this->loadObject())) {
                    if ($object->toggleStatus()) {
                        Tools::redirectAdmin($currentIndex . '&conf=5' . (($id_category = !empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1' and Tools::getValue('id_product')) ? '&id_category=' . $id_category : '') . '&token=' . $token);
                    } else {
                        $this->_errors[] = Tools::displayError('An error occurred while updating status.');
                    }
                } else {
                    $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_GET['delete' . $this->table])) {
            if ($this->tabAccess['delete'] === '1') {
                if (Validate::isLoadedObject($object = $this->loadObject()) and isset($this->fieldImageSettings)) {
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:67,代码来源:AdminProducts.php

示例8: addAttribute

 /**
  * Add a product attribute
  * @since 1.5.0.1
  *
  * @param float $price Additional price
  * @param float $weight Additional weight
  * @param float $ecotax Additional ecotax
  * @param integer $id_images Image ids
  * @param string $reference Reference
  * @param string $location Location
  * @param string $ean13 Ean-13 barcode
  * @param boolean $default Is default attribute for product
  * @param integer $minimal_quantity Minimal quantity to add to cart
  * @return mixed $id_product_attribute or false
  */
 public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1, array $id_shop_list = array())
 {
     if (!$this->id) {
         return;
     }
     $price = str_replace(',', '.', $price);
     $weight = str_replace(',', '.', $weight);
     $combination = new Combination();
     $combination->id_product = (int) $this->id;
     $combination->price = (double) $price;
     $combination->ecotax = (double) $ecotax;
     $combination->quantity = 0;
     $combination->weight = (double) $weight;
     $combination->unit_price_impact = (double) $unit_impact;
     $combination->reference = pSQL($reference);
     $combination->location = pSQL($location);
     $combination->ean13 = pSQL($ean13);
     $combination->upc = pSQL($upc);
     $combination->default_on = (int) $default;
     $combination->minimal_quantity = (int) $minimal_quantity;
     // if we add a combination for this shop and this product does not use the combination feature in other shop,
     // we clone the default combination in every shop linked to this product
     if ($default && !$this->hasAttributesInOtherShops()) {
         $id_shop_list_array = Product::getShopsByProduct($this->id);
         foreach ($id_shop_list_array as $array_shop) {
             $id_shop_list[] = $array_shop['id_shop'];
         }
     }
     if (count($id_shop_list)) {
         $combination->id_shop_list = $id_shop_list;
     }
     $combination->add();
     if (!$combination->id) {
         return false;
     }
     Product::updateDefaultAttribute($this->id);
     if (!empty($id_images)) {
         $combination->setImages($id_images);
     }
     return (int) $combination->id;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:56,代码来源:Product.php

示例9: attribute

 public function attribute()
 {
     $app = JFactory::getApplication();
     // Don't process if the combination fields have not been submitted
     if (!JeproshopCombinationModelCombination::isFeaturePublished() || !$app->input->get('attribute_combination_list')) {
         return;
     }
     if (Validate::isLoadedObject($product = $this->object)) {
         if ($this->isProductFieldUpdated('attribute_price') && (!Tools::getIsset('attribute_price') || Tools::getIsset('attribute_price') == null)) {
             $this->has_errors = Tools::displayError('The price attribute is required.');
         }
         if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list'))) {
             $this->has_errors = Tools::displayError('You must add at least one attribute.');
         }
         $array_checks = array('reference' => 'isReference', 'supplier_reference' => 'isReference', 'location' => 'isReference', 'ean13' => 'isEan13', 'upc' => 'isUpc', 'wholesale_price' => 'isPrice', 'price' => 'isPrice', 'ecotax' => 'isPrice', 'quantity' => 'isInt', 'weight' => 'isUnsignedFloat', 'unit_price_impact' => 'isPrice', 'default_on' => 'isBool', 'minimal_quantity' => 'isUnsignedInt', 'available_date' => 'isDateFormat');
         foreach ($array_checks as $property => $check) {
             if (Tools::getValue('attribute_' . $property) !== false && !call_user_func(array('Validate', $check), Tools::getValue('attribute_' . $property))) {
                 $this->errors[] = sprintf(Tools::displayError('Field %s is not valid'), $property);
             }
         }
         if (!count($this->errors)) {
             if (!isset($_POST['attribute_wholesale_price'])) {
                 $_POST['attribute_wholesale_price'] = 0;
             }
             if (!isset($_POST['attribute_price_impact'])) {
                 $_POST['attribute_price_impact'] = 0;
             }
             if (!isset($_POST['attribute_weight_impact'])) {
                 $_POST['attribute_weight_impact'] = 0;
             }
             if (!isset($_POST['attribute_ecotax'])) {
                 $_POST['attribute_ecotax'] = 0;
             }
             if (Tools::getValue('attribute_default')) {
                 $product->deleteDefaultAttributes();
             }
             // Change existing one
             if (($id_product_attribute = (int) Tools::getValue('id_product_attribute')) || ($id_product_attribute = $product->productAttributeExists(Tools::getValue('attribute_combination_list'), false, null, true, true))) {
                 if ($this->tabAccess['edit'] === '1') {
                     if ($this->isProductFieldUpdated('available_date_attribute') && (Tools::getValue('available_date_attribute') != '' && !Validate::isDateFormat(Tools::getValue('available_date_attribute')))) {
                         $this->errors[] = Tools::displayError('Invalid date format.');
                     } else {
                         $product->updateAttribute((int) $id_product_attribute, $this->isProductFieldUpdated('attribute_wholesale_price') ? Tools::getValue('attribute_wholesale_price') : null, $this->isProductFieldUpdated('attribute_price_impact') ? Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact') : null, $this->isProductFieldUpdated('attribute_weight_impact') ? Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact') : null, $this->isProductFieldUpdated('attribute_unit_impact') ? Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact') : null, $this->isProductFieldUpdated('attribute_ecotax') ? Tools::getValue('attribute_ecotax') : null, Tools::getValue('id_image_attr'), Tools::getValue('attribute_reference'), Tools::getValue('attribute_ean13'), $this->isProductFieldUpdated('attribute_default') ? Tools::getValue('attribute_default') : null, Tools::getValue('attribute_location'), Tools::getValue('attribute_upc'), $this->isProductFieldUpdated('attribute_minimal_quantity') ? Tools::getValue('attribute_minimal_quantity') : null, $this->isProductFieldUpdated('available_date_attribute') ? Tools::getValue('available_date_attribute') : null, false);
                         StockAvailable::setProductDependsOnStock((int) $product->id, $product->depends_on_stock, null, (int) $id_product_attribute);
                         StockAvailable::setProductOutOfStock((int) $product->id, $product->out_of_stock, null, (int) $id_product_attribute);
                     }
                 } else {
                     $this->errors[] = Tools::displayError('You do not have permission to add this.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     if ($product->productAttributeExists(Tools::getValue('attribute_combination_list'))) {
                         $this->errors[] = Tools::displayError('This combination already exists.');
                     } else {
                         $id_product_attribute = $product->addCombinationEntity(Tools::getValue('attribute_wholesale_price'), Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact'), Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'), Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'), Tools::getValue('attribute_ecotax'), 0, Tools::getValue('id_image_attr'), Tools::getValue('attribute_reference'), null, Tools::getValue('attribute_ean13'), Tools::getValue('attribute_default'), Tools::getValue('attribute_location'), Tools::getValue('attribute_upc'), Tools::getValue('attribute_minimal_quantity'), array(), Tools::getValue('available_date_attribute'));
                         StockAvailable::setProductDependsOnStock((int) $product->id, $product->depends_on_stock, null, (int) $id_product_attribute);
                         StockAvailable::setProductOutOfStock((int) $product->id, $product->out_of_stock, null, (int) $id_product_attribute);
                     }
                 } else {
                     $this->errors[] = Tools::displayError('You do not have permission to') . '<hr>' . Tools::displayError('edit here.');
                 }
             }
             if (!count($this->errors)) {
                 $combination = new Combination((int) $id_product_attribute);
                 $combination->setAttributes(Tools::getValue('attribute_combination_list'));
                 // images could be deleted before
                 $id_images = Tools::getValue('id_image_attr');
                 if (!empty($id_images)) {
                     $combination->setImages($id_images);
                 }
                 $product->checkDefaultAttributes();
                 if (Tools::getValue('attribute_default')) {
                     Product::updateDefaultAttribute((int) $product->id);
                     if (isset($id_product_attribute)) {
                         $product->cache_default_attribute = (int) $id_product_attribute;
                     }
                     if ($available_date = Tools::getValue('available_date_attribute')) {
                         $product->setAvailableDate($available_date);
                     }
                 }
             }
         }
     }
 }
开发者ID:jeprodev,项目名称:jeproshop,代码行数:84,代码来源:product.php

示例10: addAttribute

 /**
  * Add a product attribute
  * @since 1.5.0.1
  *
  * @param float $price Additional price
  * @param float $weight Additional weight
  * @param float $ecotax Additional ecotax
  * @param integer $id_images Image ids
  * @param string $reference Reference
  * @param string $location Location
  * @param string $ean13 Ean-13 barcode
  * @param boolean $default Is default attribute for product
  * @param integer $minimal_quantity Minimal quantity to add to cart
  * @return mixed $id_product_attribute or false
  */
 public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1, array $id_shop_list = array(), $available_date = null)
 {
     if (!$this->id) {
         return;
     }
     $price = str_replace(',', '.', $price);
     $weight = str_replace(',', '.', $weight);
     $combination = new Combination();
     $combination->id_product = (int) $this->id;
     $combination->price = (double) $price;
     $combination->ecotax = (double) $ecotax;
     $combination->quantity = 0;
     $combination->weight = (double) $weight;
     $combination->unit_price_impact = (double) $unit_impact;
     $combination->reference = pSQL($reference);
     $combination->location = pSQL($location);
     $combination->ean13 = pSQL($ean13);
     $combination->upc = pSQL($upc);
     $combination->default_on = (int) $default;
     $combination->minimal_quantity = (int) $minimal_quantity;
     $combination->available_date = $available_date;
     if (count($id_shop_list)) {
         $combination->id_shop_list = array_unique($id_shop_list);
     }
     $combination->add();
     if (!$combination->id) {
         return false;
     }
     $id_default_attribute = Product::updateDefaultAttribute($this->id);
     if ($id_default_attribute) {
         $this->cache_default_attribute = $id_default_attribute;
     }
     if (!empty($id_images)) {
         $combination->setImages($id_images);
     }
     Tools::clearColorListCache($this->id);
     return (int) $combination->id;
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:53,代码来源:Product.php

示例11: processGenerate

 public function processGenerate()
 {
     if (!is_array(Tools::getValue('options'))) {
         $this->errors[] = $this->trans('Please select at least one attribute.', array(), 'Admin.Catalog.Notification');
     } else {
         $tab = array_values(Tools::getValue('options'));
         if (count($tab) && Validate::isLoadedObject($this->product)) {
             AdminAttributeGeneratorController::setAttributesImpacts($this->product->id, $tab);
             $this->combinations = array_values(AdminAttributeGeneratorController::createCombinations($tab));
             $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations));
             // @since 1.5.0
             if ($this->product->depends_on_stock == 0) {
                 $attributes = Product::getProductAttributesIds($this->product->id, true);
                 foreach ($attributes as $attribute) {
                     StockAvailable::removeProductFromStockAvailable($this->product->id, $attribute['id_product_attribute'], Context::getContext()->shop);
                 }
             }
             SpecificPriceRule::disableAnyApplication();
             $this->product->deleteProductAttributes();
             $this->product->generateMultipleCombinations($values, $this->combinations);
             // Reset cached default attribute for the product and get a new one
             Product::getDefaultAttribute($this->product->id, 0, true);
             Product::updateDefaultAttribute($this->product->id);
             // @since 1.5.0
             if ($this->product->depends_on_stock == 0) {
                 $attributes = Product::getProductAttributesIds($this->product->id, true);
                 $quantity = (int) Tools::getValue('quantity');
                 foreach ($attributes as $attribute) {
                     if (Shop::getContext() == Shop::CONTEXT_ALL) {
                         $shops_list = Shop::getShops();
                         if (is_array($shops_list)) {
                             foreach ($shops_list as $current_shop) {
                                 if (isset($current_shop['id_shop']) && (int) $current_shop['id_shop'] > 0) {
                                     StockAvailable::setQuantity($this->product->id, (int) $attribute['id_product_attribute'], $quantity, (int) $current_shop['id_shop']);
                                 }
                             }
                         }
                     } else {
                         StockAvailable::setQuantity($this->product->id, (int) $attribute['id_product_attribute'], $quantity);
                     }
                 }
             } else {
                 StockAvailable::synchronize($this->product->id);
             }
             SpecificPriceRule::enableAnyApplication();
             SpecificPriceRule::applyAllRules(array((int) $this->product->id));
             Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts') . '&id_product=' . (int) Tools::getValue('id_product') . '&updateproduct&key_tab=Combinations&conf=4');
         } else {
             $this->errors[] = $this->trans('Unable to initialize these parameters. A combination is missing or an object cannot be loaded.');
         }
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:52,代码来源:AdminAttributeGeneratorController.php

示例12: validateOrder


//.........这里部分代码省略.........
                }
                // Optional message to attach to this order
                if (isset($message) and !empty($message)) {
                    $msg = new Message();
                    $message = strip_tags($message, '<br>');
                    if (Validate::isCleanHtml($message)) {
                        $msg->message = $message;
                        $msg->id_order = intval($order->id);
                        $msg->private = 1;
                        $msg->add();
                    }
                }
                // Insert products from cart into order_detail table
                $products = $cart->getProducts();
                $productsList = '';
                $db = Db::getInstance();
                $query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
					(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `group_reduction`, `product_quantity_discount`, `product_ean13`, `product_upc`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `ecotax_tax_rate`, `discount_quantity_applied`, `download_deadline`, `download_hash`)
				VALUES ';
                $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
                Product::addCustomizationPrice($products, $customizedDatas);
                $outOfStock = false;
                $store_all_taxes = array();
                foreach ($products as $key => $product) {
                    $productQuantity = (int) Product::getQuantity((int) $product['id_product'], $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL);
                    $quantityInStock = $productQuantity - (int) $product['cart_quantity'] < 0 ? $productQuantity : (int) $product['cart_quantity'];
                    if ($id_order_state != Configuration::get('PS_OS_CANCELED') and $id_order_state != Configuration::get('PS_OS_ERROR')) {
                        if (Product::updateQuantity($product, (int) $order->id)) {
                            $product['stock_quantity'] -= $product['cart_quantity'];
                        }
                        if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
                            $outOfStock = true;
                        }
                        Product::updateDefaultAttribute($product['id_product']);
                    }
                    $price = Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 6, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                    $price_wt = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 2, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                    /* Store tax info */
                    $id_country = (int) Country::getDefaultCountryId();
                    $id_state = 0;
                    $id_county = 0;
                    $rate = 0;
                    $id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
                    $address_infos = Address::getCountryAndState($id_address);
                    if ($address_infos['id_country']) {
                        $id_country = (int) $address_infos['id_country'];
                        $id_state = (int) $address_infos['id_state'];
                        $id_county = (int) County::getIdCountyByZipCode($address_infos['id_state'], $address_infos['postcode']);
                    }
                    $allTaxes = TaxRulesGroup::getTaxes((int) Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product']), $id_country, $id_state, $id_county);
                    // If its a freeOrder, there will be no calculation
                    if ($order->total_products > 0) {
                        // remove order discount quotepart on product price in order to obtain the real tax
                        $ratio = $price / $order->total_products;
                        $order_reduction_amount = (double) abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS)) * $ratio;
                        $tmp_price = $price - $order_reduction_amount;
                        foreach ($allTaxes as $res) {
                            if (!isset($store_all_taxes[$res->id])) {
                                $store_all_taxes[$res->id] = array();
                                $store_all_taxes[$res->id]['amount'] = 0;
                            }
                            $store_all_taxes[$res->id]['name'] = $res->name[(int) $order->id_lang];
                            $store_all_taxes[$res->id]['rate'] = $res->rate;
                            $unit_tax_amount = $tmp_price * ($res->rate * 0.01);
                            $tmp_price = $tmp_price + $unit_tax_amount;
                            $store_all_taxes[$res->id]['amount'] += $unit_tax_amount * $product['cart_quantity'];
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:67,代码来源:PaymentModule.php

示例13: updateProductAttribute

    /**
     * Update a product attribute
     *
     * @param integer $id_product_attribute Product attribute id
     * @param float $price Additional price
     * @param float $weight Additional weight
     * @param float $ecotax Additional ecotax
     * @param integer $quantity Quantity available
     * @param integer $id_image Image id
     * @param string $reference Reference
     * @param string $ean13 Ean-13 barcode
     * @param string $upc Upc barcode
     * @param string $minimal_quantity Minimal quantity
     * @return array Update result
     */
    public function updateProductAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $quantity, $id_images, $reference, $supplier_reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity)
    {
        Db::getInstance()->Execute('
		DELETE FROM `' . _DB_PREFIX_ . 'product_attribute_combination`
		WHERE `id_product_attribute` = ' . (int) $id_product_attribute);
        $price = str_replace(',', '.', $price);
        $weight = str_replace(',', '.', $weight);
        $data = array('wholesale_price' => (double) $wholesale_price, 'price' => (double) $price, 'ecotax' => (double) $ecotax, 'weight' => $weight ? (double) $weight : 0, 'unit_price_impact' => $unit ? (double) $unit : 0, 'reference' => pSQL($reference), 'supplier_reference' => pSQL($supplier_reference), 'location' => pSQL($location), 'ean13' => pSQL($ean13), 'upc' => pSQL($upc), 'default_on' => (int) $default, 'minimal_quantity' => (int) $minimal_quantity);
        if ($quantity) {
            $data['quantity'] = (int) $quantity;
        }
        if (!Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'product_attribute', $data, 'UPDATE', '`id_product_attribute` = ' . (int) $id_product_attribute) or !Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'product_attribute_image` WHERE `id_product_attribute` = ' . (int) $id_product_attribute)) {
            return false;
        }
        if ($quantity) {
            Hook::updateProductAttribute($id_product_attribute);
        }
        Product::updateDefaultAttribute($this->id);
        if (empty($id_images)) {
            return true;
        }
        $query = 'INSERT INTO `' . _DB_PREFIX_ . 'product_attribute_image` (`id_product_attribute`, `id_image`) VALUES ';
        foreach ($id_images as $id_image) {
            $query .= '(' . (int) $id_product_attribute . ', ' . (int) $id_image . '), ';
        }
        $query = trim($query, ', ');
        return Db::getInstance()->Execute($query);
    }
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:43,代码来源:Product.php

示例14: addAttribute

    /**
     * Add a product attribute
     * @since 1.5.0.1
     *
     * @param float $price Additional price
     * @param float $weight Additional weight
     * @param float $ecotax Additional ecotax
     * @param integer $id_images Image ids
     * @param string $reference Reference
     * @param string $location Location
     * @param string $ean13 Ean-13 barcode
     * @param boolean $default Is default attribute for product
     * @param integer $minimal_quantity Minimal quantity to add to cart
     * @return mixed $id_product_attribute or false
     */
    public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1, array $id_shop_list = array(), $available_date = null)
    {
        if (!$this->id) {
            return;
        }
        $price = str_replace(',', '.', $price);
        $weight = str_replace(',', '.', $weight);
        $combination = new Combination();
        $combination->id_product = (int) $this->id;
        $combination->price = (double) $price;
        $combination->ecotax = (double) $ecotax;
        $combination->quantity = 0;
        $combination->weight = (double) $weight;
        $combination->unit_price_impact = (double) $unit_impact;
        $combination->reference = pSQL($reference);
        $combination->location = pSQL($location);
        $combination->ean13 = pSQL($ean13);
        $combination->upc = pSQL($upc);
        $combination->default_on = (int) $default;
        $combination->minimal_quantity = (int) $minimal_quantity;
        $combination->available_date = $available_date;
        if (count($id_shop_list)) {
            $combination->id_shop_list = array_unique($id_shop_list);
        }
        $combination->add();
        if (!$combination->id) {
            return false;
        }
        $total_quantity = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT SUM(quantity) as quantity
			FROM ' . _DB_PREFIX_ . 'stock_available
			WHERE id_product = ' . (int) $this->id . '
			AND id_product_attribute <> 0 ');
        if (!$total_quantity) {
            Db::getInstance()->update('stock_available', array('quantity' => 0), '`id_product` = ' . $this->id);
        }
        $id_default_attribute = Product::updateDefaultAttribute($this->id);
        if ($id_default_attribute) {
            $this->cache_default_attribute = $id_default_attribute;
        }
        if (!empty($id_images)) {
            $combination->setImages($id_images);
        }
        Tools::clearColorListCache($this->id);
        return (int) $combination->id;
    }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:61,代码来源:Product.php

示例15: ajaxProcessDeleteProductAttribute

function ajaxProcessDeleteProductAttribute()
{
    ${"GLOBALS"}["josovwp"] = "product";
    if (!Combination::isFeatureActive()) {
        return;
    }
    $omvxlml = "id_product_attribute";
    $ldhbekmg = "id_product";
    $jcezymzi = "json";
    $txlbbotml = "id_product";
    ${$txlbbotml} = (int) Tools::getValue("id_product");
    ${$omvxlml} = (int) Tools::getValue("id_product_attribute");
    if (${$ldhbekmg} && Validate::isUnsignedId(${${"GLOBALS"}["dwydims"]}) && Validate::isLoadedObject(${${"GLOBALS"}["josovwp"]} = new Product(${${"GLOBALS"}["dwydims"]}))) {
        ${"GLOBALS"}["jadpodeaxuo"] = "id_product";
        $product->deleteAttributeCombination((int) ${${"GLOBALS"}["migyqxvpisl"]});
        $product->checkDefaultAttributes();
        ${"GLOBALS"}["sgtflb"] = "json";
        if (!$product->hasAttributes()) {
            ${"GLOBALS"}["hrpriieftdd"] = "id_product";
            Db::getInstance()->update("product", array("cache_default_attribute" => 0), "id_product = " . (int) ${${"GLOBALS"}["hrpriieftdd"]});
            Db::getInstance()->update("product_shop", array("cache_default_attribute" => 0), "id_product = " . (int) ${${"GLOBALS"}["dwydims"]});
        } else {
            Product::updateDefaultAttribute(${${"GLOBALS"}["jadpodeaxuo"]});
        }
        ${${"GLOBALS"}["sgtflb"]} = array("status" => "ok", "message" => Tools::displayError("Attribute deleted"));
    } else {
        ${$jcezymzi} = array("status" => "error", "message" => Tools::displayError("Cannot delete attribute"));
    }
    return Tools::jsonEncode(${${"GLOBALS"}["pthyxux"]});
}
开发者ID:evilscripts,项目名称:gy,代码行数:30,代码来源:ajax_products.php


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