문제

Magento 2 Store FrontPage의 내용 영역에 삽입 된 제품 목록 위젯이 있습니다.위젯은 다음 코드를 사용하여 삽입됩니다.

{{widget type="Magento\CatalogWidget\Block\Product\ProductsList" products_count="12" template="product/widget/content/grid.phtml" conditions_encoded="a:2:[i:1;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Combine`;s:10:`aggregator`;s:3:`all`;s:5:`value`;s:1:`1`;s:9:`new_child`;s:0:``;]s:4:`1--1`;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Product`;s:9:`attribute`;s:12:`category_ids`;s:8:`operator`;s:2:`==`;s:5:`value`;s:2:`19`;]]"}}
.

사이트를 프로덕션 모드로 전환 할 때는 통화를 변경할 때 제품 가격이 다시로드되지 않습니다.가격 새로 고침은 개발자 모드 및 일반 카테고리 페이지에서 작동합니다. 백엔드에서 BLOCK_HTML 캐시를 새로 고치면 가격이 다시로드되지만 첫 페이지보기에서 선택한 통화를 캐시합니다.위젯 캐시 TTL을 NULL로 설정하면 효과가 없습니다.

이 코드를 사용하여 레이아웃 XML을 통해 위젯을 추가하려고했습니다.

<referenceContainer name="content.bottom">
    <block class="Magento\CatalogWidget\Block\Product\ProductsList" template="product/widget/content/grid2.phtml" cacheable="false"><!--   -->
        <arguments>
             <argument name="products_count" xsi:type="number">12</argument>
             <argument name="conditions_encoded" xsi:type="string">a:2:[i:1;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Combine`;s:10:`aggregator`;s:3:`all`;s:5:`value`;s:1:`1`;s:9:`new_child`;s:0:``;]s:4:`1--1`;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Product`;s:9:`attribute`;s:12:`category_ids`;s:8:`operator`;s:2:`==`;s:5:`value`;s:2:`19`;]]</argument>
        </arguments>
    </block>
</referenceContainer>
.

나는 Ajax로드를 강제하지만 성공하지 못하는 $this->_isScopePrivate = true;Magento\CatalogWidget\Block\Product\ProductsList::__construct()를 추가하려고 시도했습니다.

제안이 우위를주는 방법, 누구든지?

도움이 되었습니까?

해결책

인식 : XSI의 인수 cache_lifetime 추가 : type null이 트릭을 수행했습니다.따라서 layout.xml을 통해 위젯을 추가하고 캐시 독립적으로 원하는 경우 다음을 수행하십시오.

<referenceContainer name="content.bottom">
    <block class="Magento\CatalogWidget\Block\Product\ProductsList" template="product/widget/content/grid2.phtml">
        <arguments>
            <argument name="products_count" xsi:type="number">12</argument>
            <argument name="conditions_encoded" xsi:type="string">a:2:[i:1;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Combine`;s:10:`aggregator`;s:3:`all`;s:5:`value`;s:1:`1`;s:9:`new_child`;s:0:``;]s:4:`1--1`;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Product`;s:9:`attribute`;s:12:`category_ids`;s:8:`operator`;s:2:`==`;s:5:`value`;s:2:`19`;]]</argument>
            <argument name="cache_lifetime" xsi:nil="true" xsi:type="null">null</argument>
        </arguments>
    </block>
</referenceContainer>
.

다른 팁

이 질문이 묻는 이래로 추가 된 기능인지 확실하지는 않지만 admin으로 위젯을 만들 때 매개 변수에 "캐시 수명 (초)"이 있습니다.

여러 통화가있는 경우, 이것은 기본적으로 하루에 지속되는 것처럼 0으로 설정해야합니다.

은 위젯이 하루 캐시 또는 캐시가 감지 할 수없는 기본 설정 일지 여부를 결정하는 코드가 포함되어 있지 않은 것처럼 보입니다.

에 사용되는 통화를 계산해야합니다.

또한 위젯이 호출되는 블록에서 cache_lifetime="1"을 시도 할 수 있습니다. 아래의 것,

{{widget type="Magento\Catalog\Block\Product\Widget\NewWidget" cache_lifetime="1" display_type="all_products" products_count="8" template="Magento_Catalog::product/widget/new/content/new_grid.phtml"}}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top