public function getDefaultOperatorInputByType() { if (null === $this->_defaultOperatorInputByType) { parent::getDefaultOperatorInputByType(); $this->_defaultOperatorInputByType['multiselect'] = array('==', '!=', '{}', '!{}'); } return $this->_defaultOperatorInputByType; }
public function validate(Varien_Object $object) { $product = Mage::getModel('catalog/product')->setStoreId($object->getStoreId())->load($object->getProductId()); $this->_entityAttributeValues[$product->getId()][$product->getStoreId()] = $product->getData($this->getAttribute()); // Required since 1.8.0.0 // Old: $this->getValue() // #var_dump($this->getAttribute(), $product->getData($this->getAttribute()), parent::validateAttribute($product)); return parent::validate($product); }
/** * Validate Product Rule Condition * * @param Varien_Object $object * @return bool */ public function validate(Varien_Object $object) { $product = false; if ($object->getProduct() instanceof Mage_Catalog_Model_Product) { $product = $object->getProduct(); } else { $product = Mage::getModel('catalog/product')->load($object->getProductId()); } $product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal()); return parent::validate($product); }
public function getValueSelectOptions() { if ($this->getAttribute() === 'type_id') { $arr = Mage::getSingleton('catalog/product_type')->getOptionArray(); $options = array(); foreach ($arr as $k => $v) { $options[] = array('value' => $k, 'label' => $v); } return $options; } return parent::getValueSelectOptions(); }
/** * Validate Product Rule Condition * * @param Varien_Object $object * @return bool */ public function validate(Varien_Object $object) { $op = $this->getOperator(); $product = false; if ($object->getProduct() instanceof Mage_Catalog_Model_Product) { $product = $object->getProduct(); } else { $product = Mage::getModel('catalog/product')->load($object->getProductId()); } $product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal()); if (!$product->getData($this->getAttribute()) && ($op != '==' || $op != '!=') && $this->getAttribute() != 'category_ids') { return false; } return parent::validate($product); }
/** * Validate product attrbute value for condition * * @param Varien_Object $object * @return bool */ public function validate(Varien_Object $object) { $attrCode = $this->getAttribute(); if ('category_ids' == $attrCode) { return $this->validateAttribute($object->getAvailableInCategories()); } elseif ('product_ids' == $attrCode) { return $this->validateAttribute($object->getId()); } elseif (!isset($this->_entityAttributeValues[$object->getId()])) { $attr = $object->getResource()->getAttribute($attrCode); if ($attr && $attr->getBackendType() == 'datetime' && !is_int($this->getValue())) { $this->setValue(strtotime($this->getValue())); $value = strtotime($object->getData($attrCode)); return $this->validateAttribute($value); } if ($attr && $attr->getFrontendInput() == 'multiselect') { $value = $object->getData($attrCode); $value = strlen($value) ? explode(',', $value) : array(); return $this->validateAttribute($value); } return parent::validate($object); } else { $result = false; // any valid value will set it to TRUE // remember old attribute state $oldAttrValue = $object->hasData($attrCode) ? $object->getData($attrCode) : null; foreach ($this->_entityAttributeValues[$object->getId()] as $storeId => $value) { $attr = $object->getResource()->getAttribute($attrCode); if ($attr && $attr->getBackendType() == 'datetime') { $value = strtotime($value); } else { if ($attr && $attr->getFrontendInput() == 'multiselect') { $value = strlen($value) ? explode(',', $value) : array(); } } $object->setData($attrCode, $value); $result |= parent::validate($object); if ($result) { break; } } if (is_null($oldAttrValue)) { $object->unsetData($attrCode); } else { $object->setData($attrCode, $oldAttrValue); } return (bool) $result; } }
/** * Attributes options * * @return Smile_VirtualCategories_Model_Rule_Condition_Product */ protected function _prepareValueOptions() { $specialAttributes = array('in_stock', 'has_image', 'has_discount', 'is_new'); if (in_array($this->getAttribute(), $specialAttributes)) { $this->setData('value_select_options', array(array('value' => '1', 'label' => Mage::helper('adminhtml')->__('Yes')))); $this->setData('value_option', array('1' => Mage::helper('adminhtml')->__('Yes'))); } else { parent::_prepareValueOptions(); } return $this; }
public function getOperatorSelectOptions() { $attributeName = array('is_new' => 'Is new', 'is_special' => 'Is special', 'out_of_stock' => 'Is Out Of Stock', 'best_seller' => 'Amount Best seller'); if ($this->getAttribute() == 'qty') { return array(array('label' => 'is', 'value' => '=='), array('label' => 'is not', 'value' => '!='), array('label' => 'equals or greater than', 'value' => '>='), array('label' => 'equals or less than', 'value' => '<='), array('label' => 'greater than', 'value' => '>'), array('label' => 'less than', 'value' => '<')); } if (!array_key_exists($this->getAttribute(), $attributeName)) { return parent::getOperatorSelectOptions(); } return array(array('label' => 'is', 'value' => '==')); }
/** * Get HTML of condition string * * @return string */ public function asHtml() { return Mage::helper('enterprise_reminder')->__('Product %s', strtolower(parent::asHtml())); }
/** * Validate Product Rule Condition * * @param Varien_Object $object * @return bool */ public function validate(Varien_Object $object) { $product = Mage::getModel('catalog/product')->load($object->getProductId())->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getRowTotal()); return parent::validate($product); }
/** * Set condition type and value * */ public function __construct() { parent::__construct(); $this->setType('enterprise_targetrule/actions_condition_product_special'); $this->setValue(null); }
/** * Set condition type and value * */ public function __construct() { parent::__construct(); $this->setType('enterprise_targetrule/rule_condition_product_attributes'); $this->setValue(null); }
public function validate(Varien_Object $object) { $product = Mage::getModel('catalog/product')->load($object->getProductId()); #var_dump($this->getAttribute(), $product->getData($this->getAttribute()), parent::validateAttribute($product)); return parent::validate($product); }
/** * Restore old attribute value * * Backward compatibility with versions < 1.13.0.0 * * @param Varien_Object $object * @param mixed $oldAttrValue */ protected function _restoreOldAttrValue($object, $oldAttrValue) { // just use the parent in case the method change in future versions if (method_exists(get_parent_class($this), '_restoreOldAttrValue')) { parent::_restoreOldAttrValue($object, $oldAttrValue); } $attrCode = $this->getAttribute(); if (is_null($oldAttrValue)) { $object->unsetData($attrCode); } else { $object->setData($attrCode, $oldAttrValue); } }
/** * Get HTML of condition string * * @return string */ public function asHtml() { return Mage::helper('enterprise_customersegment')->__('Product %s', parent::asHtml()); }