本文整理汇总了PHP中Mage_Rule_Model_Condition_Combine::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Rule_Model_Condition_Combine::validate方法的具体用法?PHP Mage_Rule_Model_Condition_Combine::validate怎么用?PHP Mage_Rule_Model_Condition_Combine::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Rule_Model_Condition_Combine
的用法示例。
在下文中一共展示了Mage_Rule_Model_Condition_Combine::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate(Varien_Object $object)
{
// for optimization if we no conditions
if (!$this->getConditions()) {
return true;
}
$origProduct = null;
if ($object->getHasChildren() && $object->getProductType() == 'configurable') {
//remember original product
$origProduct = $object->getProduct();
$origSku = $object->getSku();
foreach ($object->getChildren() as $child) {
// only one itereation.
$categoryIds = array_merge($child->getProduct()->getCategoryIds(), $origProduct->getCategoryIds());
$categoryIds = array_unique($categoryIds);
$object->setProduct($child->getProduct());
$object->setSku($child->getSku());
$object->getProduct()->setCategoryIds($categoryIds);
}
}
$result = @Mage_Rule_Model_Condition_Combine::validate($object);
if ($origProduct) {
// restore original product
$object->setProduct($origProduct);
$object->setSku($origSku);
}
return $result;
}
示例2: validate
/**
* Validate a condition with the checking of the child value
* @param Varien_Object $object
*
* @return bool
*/
public function validate(Varien_Object $object)
{
/** @var Mage_Catalog_Model_Product $product */
$product = $object->getProduct();
if (!$product instanceof Mage_Catalog_Model_Product) {
$product = Mage::getModel('catalog/product')->load($object->getProductId());
}
$valid = parent::validate($object);
if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
$children = $object->getChildren();
$valid = $children && $this->validate($children[0]);
}
return $valid;
}