doufu8127 2014-12-27 18:46 采纳率: 100%
浏览 20
已采纳

Magento解决方法以避免编辑核心功能

Hi have a function in app\code\core\Mage\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links.php

that its called when a user in admin panel enters in a downloadable product in catalog > product

The function its

 public function getConvertPDF(){

    $_prodId  = $this->getProduct()->getId();

    /*Validate if the product exist */

    if ($_prodId){
    $_proFile =$this->getLinkFile();

    $product = Mage::registry('current_product');
    if ($product->getTypeId() == 'downloadable') {
        $table = Mage::getModel('downloadable/link');
        $collection = $table->getCollection()->addProductToFilter($product->getId());
        foreach ($collection as $downloadable){
            $linkFile = $downloadable->getLinkFile();
            break;
        }
        $_proFile  = $linkFile;
    }

    $extencion = '.jpg';
    $path= 'C:/wamp/www/magento/media/downloadable/files/links';
    $pathout= 'C:/wamp/www/magento/media/catalog/product/small/';
    $test ='/small/';

     exec('convert '.$path.$_proFile.'[0] '.$pathout.$_prodId.$extencion);

/*-------------------------------------------------**/  


     $resource = Mage::getSingleton('core/resource');
     $adapter = $resource->getConnection('write');

     $bind = array(
            'value' => $test.$_prodId.$extencion
     );

     $where = array(
            'entity_id = ?'     => $_prodId,
            'attribute_id = ?'  => 86
     );

     $adapter->update($resource->getTableName('catalog_product_entity_varchar'), $bind, $where);

    }

    }

I saw a tutorial and they dont recomend to edit the core ... so my question its if there is way to make the same behavior , placing this function in other play , how should be the procedure?

  • 写回答

1条回答 默认 最新

  • dongxi8993 2014-12-30 02:28
    关注

    Functions in magento can be override by creating the functionallity of core in local...

    for example in these case

    app\code\ local\Mage\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links.php

    Update

    The function should extends the core .. for example

    extends Mage_Adminhtml_Block_Template
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么