フラットテーブルへの遅れに参加し、フラットテーブルを輸入し、eavを更新する方法
-
29-09-2020 - |
質問
これは2つの部分
になります 1.)軒の平らな表に加わるMagento Way
2.)EAVテーブルを更新するフラットテーブルにインポートします。
基本的に輸出(平らな表)と輸入(平らなテーブル)を輸出することができるが、インポート中にデータを早く延長することができる。
解決
フラットテーブルに早中テーブルに参加できます。以下は、ウィッシュリストテーブルを顧客の早中テーブルに接合するための例です。
$wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
$wishlistCollection = Mage::helper('abc')->joinEavTablesIntoCollection($wishlistCollection, 'customer_id', 'customer');
echo $wishlistCollection->getSelect()->__toString();
.
それ以降はあなたのヘルパーファイルでi.e。
public function joinEavTablesIntoCollection($collection, $mainTableForeignKey, $eavType){
$entityType = Mage::getModel('eav/entity_type')->loadByCode($eavType);
$attributes = $entityType->getAttributeCollection();
$entityTable = $collection->getTable($entityType->getEntityTable());
$index = 1;
foreach ($attributes->getItems() as $attribute){
$alias = 'table'.$index;
if ($attribute->getBackendType() != 'static'){
$table = $entityTable. '_'.$attribute->getBackendType();
$field = $alias.'.value';
$collection->getSelect()
->joinLeft(array($alias => $table),
'main_table.'.$mainTableForeignKey.' = '.$alias.'.entity_id and'.$alias.'.attribute_id = '.$attribute->getAttributeId(),
array($attribute->getAttributeCode() => $field)
);
}
$index++;
}
$collection>getSelect()>joinLeft($entityTable,'main_table.'.$mainTableForeignKey.' = '.$entityTable.'.entity_id');
return $collection;
}
.
これはあなたの質問の最初の部分への答えです。
他のヒント
Mage_Eav_Model_Entity_Collection_Abstract::joinAttribute()
メソッドを使用して、eav属性にフラット製品コレクションに参加できます。
所属していません magento.stackexchange