Называть безымянный (АНОНИМНЫЙ) блок в Magento?

Я столкнулся с действительно странным сбоем. Итак, я пытаюсь добавить блок в мой дом с помощью следующего кода {{block type="core/template" name="ves_random_products" template="page/RandomProducts.phtml"}} который прекрасно работает, показать случайные продукты из коллекции и т. д., кусок пирога.

Дело в том, что теперь я использую расширение кеша полной страницы, и мне нужно сделать этот блок динамическим, проблема в том, что Magento, похоже, не принимает «ves_random_products» в качестве имени блока, и когда страница загружена, мой блок не имеет имя (безымянный / анонимный), когда я делаю var_dump(Mage::app()->getLayout()->getAllBlocks()); имя блока отображается как «ANONYMOUS_0». И самое странное, что внутри Mage::app()->getLayout()->getAllBlocks() Я могу видеть параметр «имя» со значением «ves_random_products». Полный вывод для var_dump:

array(1) {
["ANONYMOUS_0"]=>
object(Mage_Core_Block_Template)#243 (31) {
["_viewDir":protected]=>
string(32) "/var/www/html/magento/app/design"["_viewVars":protected]=>
array(0) {
}
["_baseUrl":protected]=>
NULL
["_jsUrl":protected]=>
NULL
["_allowSymlinks":protected]=>
NULL
["_template":protected]=>
string(25) "page/RandomProducts.phtml"["_nameInLayout":protected]=>
string(12) "ANONYMOUS_0"["_layout":protected]=>
object(Mage_Core_Model_Layout)#192 (15) {
["_update":protected]=>
object(Mage_Core_Model_Layout_Update)#191 (7) {
["_elementClass":protected]=>
NULL
["_packageLayout":protected]=>
NULL
["_cacheId":protected]=>
NULL
["_cachePrefix":protected]=>
NULL
["_updates":protected]=>
array(0) {
}
["_handles":protected]=>
array(7) {
["default"]=>
int(1)
["cms_page"]=>
int(1)
["STORE_fsview"]=>
int(1)
["THEME_frontend_default_ves_superstore"]=>
int(1)
["cms_index_index"]=>
int(1)
["page_one_column"]=>
int(1)
["customer_logged_out"]=>
int(1)
}
["_subst":protected]=>
array(2) {
["from"]=>
array(2) {
[0]=>
string(11) "{{baseUrl}}"[1]=>
string(17) "{{baseSecureUrl}}"}
["to"]=>
array(2) {
[0]=>
string(26) "http://mystore.com/"[1]=>
string(27) "https://mystore.com/"}
}
}
["_blocks":protected]=>
*RECURSION*
["_output":protected]=>
array(0) {
}
["_area":protected]=>
string(8) "frontend"["_helpers":protected]=>
array(0) {
}
["_directOutput":protected]=>
bool(false)
["_xml":protected]=>
object(Mage_Core_Model_Layout_Element)#40 (0) {
}
["_cacheId":protected]=>
NULL
["_cacheTags":protected]=>
array(0) {
}
["_cacheLifetime":protected]=>
NULL
["_cacheChecksum":protected]=>
bool(false)
["_cacheSaved":protected]=>
bool(false)
["_cache":protected]=>
NULL
["_elementClass":protected]=>
string(30) "Mage_Core_Model_Layout_Element"["_xpathExtends":protected]=>
string(13) "//*[@extends]"}
["_parent":protected]=>
NULL
["_alias":protected]=>
NULL
["_anonSuffix":protected]=>
NULL
["_children":protected]=>
array(0) {
}
["_sortedChildren":protected]=>
array(0) {
}
["_childrenHtmlCache":protected]=>
array(0) {
}
["_childGroups":protected]=>
array(0) {
}
["_request":protected]=>
NULL
["_messagesBlock":protected]=>
NULL
["_isAnonymous":protected]=>
bool(true)
["_parentBlock":protected]=>
NULL
["_frameOpenTag":protected]=>
NULL
["_frameCloseTag":protected]=>
NULL
["_sortInstructions":protected]=>
array(0) {
}
["_factory":protected]=>
NULL
["_app":protected]=>
NULL
["_data":protected]=>
array(5) {
["type"]=>
string(13) "core/template"["name"]=>
string(19) "ves_random_products"["template"]=>
string(25) "page/RandomProducts.phtml"["block_params"]=>
array(3) {
["type"]=>
string(13) "core/template"["name"]=>
string(19) "ves_random_products"["template"]=>
string(25) "page/RandomProducts.phtml"}
["module_name"]=>
string(9) "Mage_Core"}
["_hasDataChanges":protected]=>
bool(true)
["_origData":protected]=>
NULL
["_idFieldName":protected]=>
NULL
["_isDeleted":protected]=>
bool(false)
["_oldFieldsMap":protected]=>
array(0) {
}
["_syncFieldsMap":protected]=>
array(0) {
}
}
}

Я безуспешно пытаюсь сделать так, чтобы у этого блока было имя, что я делаю не так? Посмотрел весь интернет и кажется, что я единственный, кто столкнулся с этой проблемой (?!). Weird. Это основной глюк? Спасибо!

0

Решение

Я не уверен, но так как похоже, что вы добавляете блок в CMS, я думаю, что имя игнорируется. Возможно, вам понадобится сохранить его в формате XML, чтобы он действительно считался по имени.

В любом случае, я не думаю, что просто назвав его, вы решите свою главную проблему, вам нужно просто пробить FPC — использование этого метода, вероятно, поможет:

https://magento.stackexchange.com/questions/35140/static-block-fpc-hole-punch

1

Другие решения

Других решений пока нет …