0

I am working on a custom theme. where I used Algolia instant search. All the products are listed through Algolia.

vendor/algolia/algoliasearch-magento-2/view/frontend/templates/instant/hit.phtml

<?php

/** @var \Algolia\AlgoliaSearch\Block\Instant\Hit $block */

$priceKey = $block->getPriceKey();

$origFormatedVar = 'price' . $priceKey . '_original_formated';
$tierFormatedVar = 'price' . $priceKey . '_tier_formated'

?>

<script type="text/template" id="instant-hit-template">
<div class="col-md-4 col-sm-6">
    <div class="result-wrapper" itemprop="itemListElement" itemscope itemtype="http://schema.org/Product">
        <a itemprop="url" href="{{url}}" class="result" data-objectid="{{objectID}}" data-position="{{__position}}">
            <div class="result-content">
                <div class="result-thumbnail">
                    {{#image_url}}<img itemprop="image" src="{{{ image_url }}}" />{{/image_url}}
                    {{^image_url}}<span class="no-image"></span>{{/image_url}}
                </div>
                <div class="result-sub-content">
                    <h3 itemprop="name" class="result-title text-ellipsis">
                        {{{ _highlightResult.name.value }}}
                    </h3>
                    <div class="ratings">
                        <div class="result-sub-content">
                            <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer" class="price">
                                <div class="price-wrapper">
                                    <div>
                                        <span itemprop="lowPrice" class="after_special
                                                {{#<?php echo $block->escapeHtml($origFormatedVar); ?>}}
                                                    promotion
                                                {{/<?php echo $block->escapeHtml($origFormatedVar); ?>}}">
                                            {{price<?php echo $block->escapeHtml($priceKey); ?>_formated}}
                                        </span>
                                        {{#<?php echo $block->escapeHtml($origFormatedVar); ?>}}
                                            <span itemprop="highPrice" class="before_special">
                                                {{<?php echo $block->escapeHtml($origFormatedVar); ?>}}
                                            </span>
                                        {{/<?php echo $block->escapeHtml($origFormatedVar); ?>}}
                                        {{#<?php echo $block->escapeHtml($tierFormatedVar); ?>}}
                                            <span class="tier_price">
                                                <?php echo __('As low as') ?>
                                                <span class="tier_value">{{<?php echo $block->escapeHtml($tierFormatedVar); ?>}}</span>
                                            </span>
                                        {{/<?php echo $block->escapeHtml($tierFormatedVar); ?>}}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="result-description text-ellipsis">{{{ _highlightResult.description.value }}}</div>

                    {{#isAddToCartEnabled}}
                    <form data-role="tocart-form" action="{{ addToCart.action }}" method="post">
                        <input type="hidden" name="product" value="{{objectID}}">
                        <input type="hidden" name="uenc" value="{{ addToCart.uenc }}">
                        <input name="form_key" type="hidden" value="{{ addToCart.formKey }}">
                        <button type="submit" title="<?php echo __('Add to Cart') ?>" class="action tocart primary" data-objectid="{{objectID}}" data-position="{{__position}}">
                            <span><?php echo __('Add to Cart') ?></span>
                        </button>
                    </form>
                    {{/isAddToCartEnabled}}
                </div>
            </div>
            <div class="algolia-clearfix"></div>
        </a>
    </div>
</div>

as can see that there is no option of add to wish list.

is there any way to add this button? I have extended its block with Magento's default block but still the default code for add to wish list is not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.