少し違うアプローチをお勧めします。管理インターフェースの拡張は困難ですが、可能です。これがより簡単な方法です。
方法#1-すばやく簡単
製品のリストを調べるスクリプトを自分で作成します。属性タイプ、カテゴリで選択することも、すべてを選択することもできます。次に、そのコレクションをループし、商品ごとにタイトルを取得し、映画APIをクエリして、商品の属性を設定します。次に、製品を保存して、次の製品に移動します。このようなもの:
注:管理者でカスタム属性を作成し、それらを属性セットに割り当ててください。
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app('default');
function getVideoDataFromAPI($title)
{
// get your data from the API here...
return $data;
}
$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('attribute_set_id', $yourAttributeSetId)
->addAttributeToFilter('year', ''); // <-- Set a field here that will be empty by default, and filled by the API. This is '' because it won't be null.
foreach ( $collection->getAllIds() as $id ) {
$product = Mage::getModel('catalog/product')->load($id);
$videoData = getVideoDataFromAPI($product->getName());
if ( empty($videoData) ) { continue; }
$product->setYear($videoData['year'])
->setRating($videoData['rating'])
->save();
}
?>
方法#2-上記を実行しますが、カスタム拡張機能を使用します
私はいつもスクリプトよりも拡張機能が好きです。それらはより安全でより強力です。拡張機能を使用すると、製品の管理者リストを作成したり、好きなようにフィルタリングしたり、ビデオデータを手動でプルするための一括アクションを実行したりできます。定期的にプルするようにcronジョブで設定することもできます。