Ejemplo n.º 1
0
 protected function _beforeSaveEditedFieldValue($type, $config, $params, $entity, $value)
 {
     if ($entity->getId() == Mage_Customer_Model_Group::NOT_LOGGED_IN_ID) {
         // Prevent from unique check (also made in original form, because code input is disabled and setCode is forced)
         $entity->setCode(null);
     }
     return parent::_beforeSaveEditedFieldValue($type, $config, $params, $entity, $value);
 }
Ejemplo n.º 2
0
 protected function _beforeSaveEditedFieldValue($type, $config, $params, $entity, $value)
 {
     if (($result = $entity->validate()) !== true && is_string($result)) {
         Mage::throwException($result);
     }
     // Ensure page groups will be succesfully saved, and not resetted
     $this->_prepareWidgetPageGroups($entity);
     return parent::_beforeSaveEditedFieldValue($type, $config, $params, $entity, $value);
 }
Ejemplo n.º 3
0
 protected function _beforeSaveEditedFieldValue($type, $config, $params, $entity, $value)
 {
     $model = Mage::getModel('catalogsearch/query');
     $model->setStoreId($entity->getStoreId());
     $model->loadByQueryText($entity->getQueryText());
     if ($model->getId() && $model->getId() != $entity->getId()) {
         Mage::throwException(Mage::helper('catalog')->__('Search Term with such search query already exists.'));
     }
     $entity->setIsProcessed(0);
     return parent::_beforeSaveEditedFieldValue($type, $config, $params, $entity, $value);
 }
Ejemplo n.º 4
0
 protected function _beforeSaveEditedFieldValue($type, $config, $params, $entity, $value)
 {
     $category = Mage::registry('current_category')->getId() ? Mage::registry('current_category') : null;
     if ($category) {
         $entity->setCategoryId($category->getId());
     }
     $product = Mage::registry('current_product')->getId() ? Mage::registry('current_product') : null;
     if ($product) {
         $entity->setProductId($product->getId());
     }
     if ($product || $category) {
         $catalogUrlModel = Mage::getSingleton('catalog/url');
         $idPath = $catalogUrlModel->generatePath('id', $product, $category);
         // If redirect specified try to find friendly URL
         $found = false;
         if (in_array($entity->getOptions(), array('R', 'RP'))) {
             $rewrite = Mage::getResourceModel('catalog/url')->getRewriteByIdPath($idPath, $entity->getStoreId());
             if (!$rewrite) {
                 Mage::throwException('Chosen product does not associated with the chosen store or category.');
             }
             if ($rewrite->getId() && $rewrite->getId() != $entity->getId()) {
                 $entity->setIdPath($idPath);
                 $entity->setTargetPath($rewrite->getRequestPath());
                 $found = true;
             }
         }
         if (!$found) {
             $entity->setIdPath($idPath);
             $entity->setTargetPath($catalogUrlModel->generatePath('target', $product, $category));
         }
     }
     return parent::_beforeSaveEditedFieldValue($type, $config, $params, $entity, $value);
 }