本文整理汇总了PHP中Attribute::getAttributeQty方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::getAttributeQty方法的具体用法?PHP Attribute::getAttributeQty怎么用?PHP Attribute::getAttributeQty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute::getAttributeQty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayFormInformations
function displayFormInformations($obj, $currency, $languages, $defaultLanguage)
{
global $currentIndex, $cookie;
$iso = Language::getIsoById(intval($cookie->id_lang));
$divLangName = 'cname¤cdesc¤cdesc_short¤clink_rewrite¤cmeta_description¤cmeta_title¤cmeta_keywords¤ctags¤cavailable_now¤cavailable_later';
$qty_state = 'readonly';
$qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product'));
if ($qty === false) {
if (Validate::isLoadedObject($obj)) {
$qty = $this->getFieldValue($obj, 'quantity');
} else {
$qty = 1;
}
$qty_state = '';
}
$cover = Product::getCover($obj->id);
$link = new Link();
//includeDatepicker(array('reduction_from', 'reduction_to'));
echo '
<div class="tab-page" id="step1">
<h4 class="tab">1. ' . $this->l('Info.') . '</h4>
<b>' . $this->l('Product global informations') . '</b> - ';
if (isset($obj->id)) {
echo '
<a href="' . $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $defaultLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), intval($cookie->id_lang))) . '"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>';
if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) {
echo ' -
<a href="index.php?tab=AdminStatsModules&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStatsModules' . intval(Tab::getIdFromClassName('AdminStatsModules')) . intval($cookie->id_employee)) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>';
}
}
echo '
<hr class="clear"/>
<br />
<table cellpadding="5" style="width:100%">
<tr>
<td class="col-left">' . $this->l('Name:') . '</td>
<td style="padding-bottom:5px;">';
foreach ($languages as $language) {
echo ' <div id="cname_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
<input size="55" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '"
value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="copy2friendlyURL();"' : '') . ' onchange="updateCurrentText();" /><sup> *</sup>
<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span>
</div>';
}
$this->displayFlags($languages, $defaultLanguage, $divLangName, 'cname');
echo '<script type="text/javascript">updateCurrentText();</script>
</td>
</tr>
<tr>
<td style="vertical-align:top">' . $this->l('Status:') . '</td>
<td style="padding-bottom:5px;">
<input style="float:left;" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
<label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label>
<br style="clear:both;" />
<input style="float:left;" type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
<label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . '</label>
</td>
</tr>
<tr>
<td>' . $this->l('Manufacturer:') . '</td>
<td style="padding-bottom:5px;">
<select name="id_manufacturer" id="id_manufacturer">
<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) {
echo ' <option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option>
<option disabled="disabled">----------</option>';
}
echo '
</select> <a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . intval(Tab::getIdFromClassName('AdminManufacturers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
<script type="text/javascript">
var ajaxManufacturersClicked = false;
$("select#id_manufacturer").focus(
function() {
if (ajaxManufacturersClicked == true) return; else ajaxManufacturersClicked = true;
$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductManufacturers:1},
function(j) {
var options = \'\';
for (var i = 0; i < getE("id_manufacturer").options.length; i++)
{
if (getE("id_manufacturer").options[i].innerHTML == \'----------\')
options += \'<option disabled="disabled">----------</option>\';
else
options += \'<option value="\' + getE("id_manufacturer").options[i].value + \'">\' + getE("id_manufacturer").options[i].innerHTML + \'</option>\';
}
for (var i = 0; i < j.length; i++)
options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
$("select#id_manufacturer").html(options);
}
)
}
);
</script>
</td>
</tr>
<tr>
<td>' . $this->l('Supplier:') . '</td>
<td style="padding-bottom:5px;">
<select name="id_supplier" id="id_supplier">
<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) {
//.........这里部分代码省略.........
示例2: updateQtyProduct
/**
* Update array with veritable quantity
*
* @deprecated since 1.5.0
* @param array &$arr
* @return bool
*/
public static function updateQtyProduct(&$arr)
{
Tools::displayAsDeprecated();
$id_product = (int) $arr['id_product'];
$qty = Attribute::getAttributeQty($id_product);
if ($qty !== false) {
$arr['quantity'] = (int) $qty;
return true;
}
return false;
}
示例3: addProducts
function addProducts($client, $ids = array())
{
//update currency
// update_currency();
$default_tz = date_default_timezone_get();
date_default_timezone_set('UTC');
$category = new Category(1, 1);
$sql = "select p.id_product, DATEDIFF(NOW(), p.`date_add`) as 'age'\n from ps_product p\n where p.price > 0 and p.active = 1";
$productScores = array();
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($products as $product) {
$productScores[$product['id_product']] = array('age' => $product['age'], 'week_sold' => 0, 'month_sales' => 0, 'year_sales' => 0);
}
$sql = "select p.`id_product`, sum(od.product_quantity) as 'quantity'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 \n and p.active = 1\n and o.date_add > now() - INTERVAL 7 DAY\n group by p.id_product";
$week_quantities = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($week_quantities as $week_quantity) {
$productScores[$week_quantity['id_product']]['week_sold'] = $week_quantity['quantity'];
}
$sql = "select p.`id_product`, round(sum(od.product_quantity * od.product_price * 55 / o.`conversion_rate`)) as 'month_revenue'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 and p.active = 1\n and o.date_add > now() - INTERVAL 30 DAY\n group by p.id_product";
$month_sales = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($month_sales as $month_sale) {
$productScores[$month_sale['id_product']]['month_sales'] = $month_sale['month_revenue'];
}
$sql = "select p.`id_product`, round(sum(od.product_quantity * od.product_price * 55 / o.`conversion_rate`)) as 'year_revenue'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 and p.active = 1\n and o.date_add > now() - INTERVAL 365 DAY\n group by p.id_product";
$year_sales = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($year_sales as $year_sale) {
$productScores[$year_sale['id_product']]['year_sales'] = $year_sale['year_revenue'];
}
foreach ($products as $product) {
$productScores[$product['id_product']]['score'] = getWeekSalesScore($productScores[$product['id_product']]['week_sold']) + getAgeScore($productScores[$product['id_product']]['age']) + getMonthScore($productScores[$product['id_product']]['month_sales']) + getYearScore($productScores[$product['id_product']]['year_sales']);
}
$docs = array();
$link = new Link();
$count = 0;
$update = $client->createUpdate();
foreach ($products as $product) {
if (!empty($ids) && !in_array((int) $product['id_product'], $ids)) {
continue;
}
$productObj = new Product((int) $product['id_product'], true, 1);
print_r('\\n' . 'reindexing ' . $product['id_product']);
if (!$productObj->active) {
deleteProduct($productObj->id, $client);
continue;
}
$doc = $update->createDocument();
$doc->id_product = $productObj->id;
$doc->reference = $productObj->reference;
$doc->name = $productObj->name;
$doc->description = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description);
$doc->description_short = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short);
$doc->brand_id = $productObj->id_manufacturer;
$doc->brand_name = $productObj->manufacturer_name;
$doc->style_tips = $productObj->description_short;
$doc->alphaNameSort = $productObj->name;
$dbresult = $productObj->getWsCategories();
$catIds = array();
foreach ($dbresult as $catIdRow) {
$catIds[] = $catIdRow['id'];
}
$category_names = array();
foreach ($catIds as $catID) {
$category = new Category((int) $catID);
$category_names[] = $category->getName(1);
}
$doc->cat_name = $category_names;
$doc->cat_id = $catIds;
$doc->tags = $productObj->getTags(1);
$doc->shipping_sla = $productObj->shipping_sla ? $productObj->shipping_sla : 0;
$doc->weight = $productObj->weight ? $productObj->weight : 0.5;
if (isset($productObj->work_type)) {
$doc->work_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->work_type ? $productObj->work_type : '');
}
if (isset($productObj->garment_type)) {
$doc->garment_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->garment_type ? $productObj->garment_type : '');
}
if (isset($productObj->blouse_length)) {
$doc->blouse_length = $productObj->blouse_length ? $productObj->blouse_length : '';
}
$doc->height = $productObj->height;
$doc->width = $productObj->width;
$atributeQty = Attribute::getAttributeQty($productObj->id);
if ($productObj->quantity > 0 || $atributeQty > 0) {
$doc->inStock = true;
} else {
$doc->inStock = false;
}
$doc->isPlusSize = $productObj->is_plussize ? true : false;
$doc->isRTS = $productObj->is_rts ? true : false;
$doc->quantity = $productObj->quantity ? $productObj->quantity : ($atributeQty ? $atributeQty : 0);
//Indian Price
$doc->offer_price_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, true, 1, false, NULL, NULL, IND_ADDRESS_ID);
$doc->offer_price_in_rs = Tools::convertPrice($doc->offer_price_in, 4);
$doc->mrp_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, false, 1, false, NULL, NULL, IND_ADDRESS_ID);
if ($doc->mrp_in > $doc->offer_price_in) {
$doc->discount_in = Tools::ps_round(($doc->mrp_in - $doc->offer_price_in) / $doc->mrp_in * 100);
}
//Worldwide Price
$doc->offer_price = $productObj->getPrice();
$doc->offer_price_rs = Tools::convertPrice($doc->offer_price, 4);
//.........这里部分代码省略.........
示例4: displayFormInformations
function displayFormInformations($obj, $currency)
{
parent::displayForm(false);
global $currentIndex, $cookie, $link;
$default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'));
$iso = Language::getIsoById((int) $cookie->id_lang);
$has_attribute = false;
$qty_state = 'readonly';
$qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product'));
if ($qty === false) {
if (Validate::isLoadedObject($obj)) {
$qty = $this->getFieldValue($obj, 'quantity');
} else {
$qty = 1;
}
$qty_state = '';
} else {
$has_attribute = true;
}
$cover = Product::getCover($obj->id);
$this->_applyTaxToEcotax($obj);
echo '
<div class="tab-page" id="step1">
<h4 class="tab">1. ' . $this->l('Info.') . '</h4>
<script type="text/javascript">
$(document).ready(function() {
updateCurrentText();
updateFriendlyURL();
$.ajax({
url: "' . dirname($currentIndex) . '/ajax.php",
cache: false,
dataType: "json",
data: "ajaxProductManufacturers=1",
success: function(j) {
var options = $("select#id_manufacturer").html();
if (j)
for (var i = 0; i < j.length; i++)
options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
$("select#id_manufacturer").html(options);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert(\'Manufacturer ajax error: \'+textStatus);
}
});
$.ajax({
url: "' . dirname($currentIndex) . '/ajax.php",
cache: false,
dataType: "json",
data: "ajaxProductSuppliers=1",
success: function(j) {
var options = $("select#id_supplier").html();
if (j)
for (var i = 0; i < j.length; i++)
options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
$("select#id_supplier").html(options);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert(\'Supplier ajax error: \'+textStatus);
}
});
if ($(\'#available_for_order\').is(\':checked\')){
$(\'#show_price\').attr(\'checked\', \'checked\');
$(\'#show_price\').attr(\'disabled\', \'disabled\');
}
else {
$(\'#show_price\').attr(\'disabled\', \'\');
}
});
</script>
<b>' . $this->l('Product global information') . '</b> - ';
$preview_url = '';
if (isset($obj->id)) {
$preview_url = $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $this->_defaultFormLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), (int) $cookie->id_lang));
if (!$obj->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$token = Tools::encrypt('PreviewProduct' . $obj->id);
$preview_url .= $obj->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
}
echo '
<a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&deleteproduct&token=' . $this->token . '" style="float:right;"
onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');">
<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" title="' . $this->l('Delete this product') . '" /> ' . $this->l('Delete this product') . '</a>
<a href="' . $preview_url . '" target="_blank"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>';
if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) {
echo ' - <a href="index.php?tab=AdminStats&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStats' . (int) Tab::getIdFromClassName('AdminStats') . (int) $cookie->id_employee) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>';
}
}
echo '
<hr class="clear"/>
<br />
<table cellpadding="5" style="width: 50%; float: left; margin-right: 20px; border-right: 1px solid #E0D0B1;">
<tr>
<td class="col-left">' . $this->l('Name:') . '</td>
<td style="padding-bottom:5px;" class="translatable">';
foreach ($this->_languages as $language) {
//.........这里部分代码省略.........
示例5: getProductDoc
/**
* @param Solarium_Query_Update $update
* @param Link $link
* @param Product $productObj
* @return Solarium_Document_ReadWrite
*/
private static function getProductDoc($update, $link, $productObj)
{
$doc = $update->createDocument();
$doc->id_product = $productObj->id;
$doc->reference = $productObj->reference;
$doc->name = $productObj->name;
//$doc->description = $productObj->description;
$doc->description = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description);
$doc->description_short = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short);
$doc->brand_id = $productObj->id_manufacturer;
$doc->brand_name = $productObj->manufacturer_name;
$doc->style_tips = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short);
$doc->alphaNameSort = $productObj->name;
$dbresult = $productObj->getWsCategories();
$catIds = array();
foreach ($dbresult as $catIdRow) {
$catIds[] = $catIdRow['id'];
}
$category_names = array();
foreach ($catIds as $catID) {
$category = new Category((int) $catID);
$category_names[] = $category->getName(1);
}
$doc->cat_name = $category_names;
$doc->cat_id = $catIds;
$doc->tags = $productObj->getTags(1);
$doc->shipping_sla = $productObj->shipping_sla;
$doc->weight = $productObj->weight ? $productObj->weight : 0.5;
$doc->cashback_percentage = $productObj->cashback_percentage;
if (isset($productObj->work_type)) {
$doc->work_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->work_type ? $productObj->work_type : '');
}
if (isset($productObj->garment_type)) {
$doc->garment_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->garment_type ? $productObj->garment_type : '');
}
if (isset($productObj->blouse_length)) {
$doc->blouse_length = $productObj->blouse_length ? $productObj->blouse_length : '';
}
$doc->height = $productObj->height;
$doc->width = $productObj->width;
$atributeQty = Attribute::getAttributeQty($productObj->id);
if ($productObj->quantity > 0 || $atributeQty > 0) {
$doc->inStock = true;
} else {
$doc->inStock = false;
}
$doc->isPlusSize = $productObj->is_plussize ? true : false;
$doc->isRTS = $productObj->is_rts ? true : false;
$doc->quantity = $productObj->quantity ? $productObj->quantity : ($atributeQty ? $atributeQty : 0);
$date = DateTime::createFromFormat('Y-m-d H:i:s', $productObj->date_add);
$doc->date_add = $date->format("Y-m-d\\TG:i:s\\Z");
$productObj->fabric = trim($productObj->fabric);
$productObj->fabric = preg_replace('/\\s+/', '-', $productObj->fabric);
$doc->fabric = strtolower($productObj->fabric);
$doc->is_customizable = $productObj->is_customizable;
if (isset($productObj->generic_color) && !empty($productObj->generic_color)) {
$colors = explode(',', $productObj->generic_color);
$indexed_colors = array();
foreach ($colors as $color) {
$indexed_colors[] = strtolower(preg_replace('/\\s+/', '-', trim($color)));
}
$doc->color = $indexed_colors;
}
if (isset($productObj->stone) && !empty($productObj->stone)) {
$stones = explode(',', $productObj->stone);
$indexed_stones = array();
foreach ($stones as $stone) {
$indexed_stones[] = strtolower(preg_replace('/\\s+/', '-', trim($stone)));
}
$doc->stone = $indexed_stones;
}
if (isset($productObj->plating) && !empty($productObj->plating)) {
$platings = explode(',', $productObj->plating);
$indexed_platings = array();
foreach ($platings as $plating) {
$indexed_platings[] = strtolower(preg_replace('/\\s+/', '-', trim($plating)));
}
$doc->plating = $indexed_platings;
}
if (isset($productObj->material) && !empty($productObj->material)) {
$materials = explode(',', $productObj->material);
$indexed_materials = array();
foreach ($materials as $material) {
$indexed_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($material)));
}
$doc->material = $indexed_materials;
}
if (isset($productObj->look) && !empty($productObj->look)) {
$looks = explode(',', $productObj->look);
$indexed_looks = array();
foreach ($looks as $look) {
$indexed_looks[] = strtolower(preg_replace('/\\s+/', '-', trim($look)));
}
$doc->look = $indexed_looks;
//.........这里部分代码省略.........