本文整理匯總了PHP中Varien_Event_Observer::getAdapter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getAdapter方法的具體用法?PHP Varien_Event_Observer::getAdapter怎麽用?PHP Varien_Event_Observer::getAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getAdapter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: linkProductsToProfile
/**
* Link imported products to profile.
* @param Varien_Event_Observer $observer
* @throws Zend_Db_Exception
*/
public function linkProductsToProfile(Varien_Event_Observer $observer)
{
/** @var AvS_FastSimpleImport_Model_Import_Entity_Product $adapter */
$adapter = $observer->getAdapter();
/** @var $coreResource Mage_Core_Model_Resource */
$coreResource = Mage::getSingleton('core/resource');
$entityProfileTable = $coreResource->getTableName('ho_import/entity');
$entityTypeId = $adapter->getEntityTypeId();
$now = Mage::helper('ho_import')->getCurrentDatetime();
while ($bunch = $adapter->getNextBunch()) {
$entityProfileData = array();
foreach ($bunch as $rowNum => $rowData) {
if ($adapter->getRowScope($rowData) !== Mage_ImportExport_Model_Import_Entity_Product::SCOPE_DEFAULT) {
continue;
}
if (!isset($rowData['ho_import_profile'])) {
continue;
}
$entity = $adapter->getEntityBySku($rowData[$adapter::COL_SKU]);
$entityProfileData[] = array('profile' => $rowData['ho_import_profile'], 'entity_type_id' => $entityTypeId, 'entity_id' => $entity['entity_id'], 'updated_at' => $now, 'created_at' => $now);
}
if ($entityProfileData) {
$adapter->getConnection()->insertOnDuplicate($entityProfileTable, $entityProfileData, array('updated_at'));
}
}
}
示例2: addSortArray
/**
* Add a new filter to the the Twig instance
*
* @param Varien_Event_Observer $observer
*/
public function addSortArray($observer)
{
$twig = $observer->getTwig();
$policy = $observer->getPolicy();
$this->_adapter = $observer->getAdapter();
$policy->setAllowedFilter('sort_array');
$filter = new Twig_SimpleFilter('sort_array', array($this, 'sortArray'));
$twig->addFilter($filter);
}
示例3: addUnserializeString
/**
* Add a new filter to the the Twig instance
*
* @param Varien_Event_Observer $observer
*/
public function addUnserializeString($observer)
{
$twig = $observer->getTwig();
$policy = $observer->getPolicy();
$this->_adapter = $observer->getAdapter();
$policy->setAllowedFilter('unserialize_string');
$filter = new Twig_SimpleFilter('unserialize_string', array($this, 'unserializeString'));
$twig->addFilter($filter);
}