2012-11-02 27 views

回答

0

如果您觀看MySQl日誌,則由magento所做的調用有時可能長達500行或更長......這些調用是使用XML文件動態構建的。手動操縱Magento的數據,最好的辦法是使用MAGE::電話或者使用與數據庫直接連接:

$read = $resource->getConnection('core_read'); 
$sql = "select * from [YOUR_TABLE] where 1 limit 1"; 
$result = $read->query($sql); 

它要麼是或看起來像電話:

$value = 'some value'; 
$item->setData('some_key', $value); 
$item->save(); 

Magento的是面向對象的,因此這些是在Magento中檢索/設置數據的最常用和最常用的方式。我希望有所幫助。

0

knowledge base中閱讀第5章。

你不是真的問一個問題,所以沒有人可以幫助的具體細節,我總是發現你學習最好的做法,我發現最好的方法來攪亂magento是創建一個test.php文件在shell/與以下內容:(例如)

<?php 
require('abstract.php'); 

class Test extends Mage_Shell_Abstract 
{ 
    function run(){ //call your functions here 
     echo 'running ..'; 
     $this->database(); 
    } 

    function database() { //you can create as many functions as you like 
     $entityId = '4449'; //product id 

     $product=Mage::getModel("catalog/product")->load($entityId); 
     var_dump($product->getAttributeText('size')); 
    } 
} 

$test = new Test(); 
$test -> run(); 

然後你可以從控制檯運行: php test.php

,並在我的例子返回 running ..string(11) "Extra Large"

希望這可以幫助你,下次更具體。

1

我會建議讀了從艾倫風暴這個博客帖子: http://alanstorm.com/magento_models_orm

他相當升技解釋了有關Magento的ORM系統,而在我看來那整個網站爲任何磁開發一個很好的資源。

相關問題