3. СобытиеMage_Index_Model_EventСобытие – то, что происходит в некоторый момент времени и рассматривается как изменение состояния сущности.Событие хранит информацию о сущности, с которой произошло действие и тип действия.Типы изменений сущности (event type)Сохранение (SAVE)Удаление (DELETE)Групповая обработка (MASS_ACTION)
5. Изменения в абстрактной моделиПроцесс сохранения_getResource()->beginTransaction()_beforeSave()_getResource()->save()_afterSave()_getResource()->commit()afterCommitCallback()Новые событияmodel_save_commit_after{eventPrefix}_save_commit_after
6. Изменения в абстрактной моделиПроцесс удаления_getResource()->beginTransaction()_beforeDelete()_getResource()->delete()_afterDelete()_getResource()->commit()_afterDeleteCommit()Новые событияmodel_delete_commit_after{eventPrefix}_delete_commit_after
8. Процессы и индексаторыИндексатор может работать в 2х режимах:в режиме реального времени (MODE_REAL_TIME)в ручном режиме (MODE_MANUAL)У каждого индексатора есть текущий статус:работает (STATUS_RUNNING)режим ожидания (STATUS_PENDING)необходимо перестроить (STATUS_REQUIRE_REINDEX)СобытиеREQUIRE_REINDEXMODE MANUALNew Indexer
10. CatalogInventory Stock StatusЦель оптимизировать затраты на подсчет возможности покупки товара при отображении товаров в каталоге, поиске и т.д.Мотивация для простых (simple) товаров - динамически определить доступность не является трудозатратной операцией, чего не скажешь о составных (composite), для которых нужно учитывать статус всех его составляющихЗадача сделать предварительно подсчитанный статус для каждого товара с учетом склада и веб сайта
18. Шаг 4: Изменение конфигурацииprotected$_relatedConfigSettings = array( Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, Mage_CatalogInventory_Helper_Data::XML_PATH_SHOW_OUT_OF_STOCK);public functionmatchEvent(Mage_Index_Model_Event$event){// check saved result in $event and return it if ($entity == Mage_Core_Model_Config_Data::ENTITY) {$configData= $event->getDataObject();$path = $configData->getPath();if (in_array($path, $this->_relatedConfigSettings)) {$result = $configData->isValueChanged(); } else {$result = false; } } else {$result = parent::matchEvent($event); }// save result in $event and return it}
28. Индекс цен для B2BЦель Создать новый тип товара B2BСправка В2В – сокращение от английских слов «businesstobusiness», в буквальном переводе – бизнес для бизнеса. Это сектор рынка, который работает не на конечного, рядового потребителя, а на такие же компании, то есть на другой бизнес.Задача Новый тип товара, который наследует поведение простого товара (simple), но имеет возможность указать цену для каждой группы пользователей (customer group)
29. Индекс цен для B2BЗнакомство с интерфейсом Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Interfacepublic functionreindexAll();public functionreindexEntity($entityIds);public functionregisterEvent(Mage_Index_Model_Event$event);Создаем свой индексаторclass Mageconf_B2b_Model_Mysql4_Indexer_Price extendsMage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Default{}
30. Индекс цен для B2BЗнакомство с …Indexer_Price_Defaultpublic functionreindexAll(){$this->useIdxTable(true);$this->_prepareFinalPriceData();$this->_applyCustomOption();$this->_movePriceDataToIndexTable();return$this;}public functionreindexEntity($entityIds){$this->_prepareFinalPriceData($entityIds);$this->_applyCustomOption();$this->_movePriceDataToIndexTable();return$this;}
31. Индекс цен для B2Bprotected function _getDefaultFinalPriceTable(){if($this->useIdxTable()) {return$this->getTable('catalog/product_price_indexer_final_idx');}return$this->getTable('catalog/product_price_indexer_final_tmp');}