Мне написали, что надо сменить проверку даты создания на проверку кол-ва наличия.
<?PHP
defined('_JEXEC') or die;
error_reporting(E_ALL & ~E_NOTICE);
class plgJshoppingProductsAuto_label extends JPlugin {
function onBeforeDisplayProductList(&$products){
$label_id = $this->params->get('label_id', 0);
$sec_number = $this->params->get('day_number', 0)*24*60*60;
$end_time = strtotime("now")-$sec_number;
if (!$label_id || !$sec_number) return;
require_once (JPATH_SITE.DS.'components'.DS.'com_jshopping'.DS."lib".DS."factory.php");
require_once (JPATH_SITE.DS.'components'.DS.'com_jshopping'.DS."lib".DS."functions.php");
$jshopConfig = &JSFactory::getConfig();
$product = &JTable::getInstance('product', 'jshop');
$productlabel = &JTable::getInstance('productlabel', 'jshop');
$productlabel->load($label_id);
foreach($products as $key=>$prod) {
$product->load($prod->product_id);
if (strtotime($product->product_date_added) >= $end_time && !$prod->label_id) {
$products[$key]->label_id = $productlabel->id;
$products[$key]->_label_image = $jshopConfig->image_labels_live_path.'/'.$productlabel->image;
$products[$key]->_label_name = $productlabel->name;
}
}
}
}
и еще, но вроде этот код не за это отвечает
<?PHP
defined( '_JEXEC' ) or die;
error_reporting(E_ALL & ~E_NOTICE);
class JFormFieldLabel extends JFormField {
public $type ='Label';
protected function getInput(){
require_once (JPATH_SITE.DS.'components'.DS.'com_jshopping'.DS."lib".DS."factory.php");
$tmp = new stdClass();
$tmp->id = 0;
$tmp->name = JText::_('JSELECT');
$element_1 = array($tmp);
$productLabel = &JTable::getInstance('productLabel', 'jshop');
$listLabels = $productLabel->getListLabels();
$elementes_select =array_merge($element_1 , $listLabels);
$ctrl = $this->name ;
$value = empty($this->value) ? '' : $this->value;
return JHTML::_('select.genericlist', $elementes_select, $ctrl,'class="inputbox"','id', 'name', $value );
}
}
?>