EmicoEcommerce / Magento2Tweakwise-archived

Magento 2 module for Tweakwise integration
Other
9 stars 25 forks source link

Add robots meta tag to attribute landing pages #107

Closed rlaven closed 4 years ago

rlaven commented 4 years ago

Issue Brief

It would be better for SEO purposes to set the robots meta tag on attribute landingpages to help the indexing of pages by spiders.

Environment

Steps to reproduce

Install Magento 2.3.2 Install and configure Tweakwise Install and configure attribute landing pages Check the head of an attribute landing page via the browser inspector.

Actual result

The robots meta tag is not set on attribute landing pages

Expected result

The robots meta tag is set on attribute landing pages

edwinljacobs commented 4 years ago

Hello,

I cannot reproduce your issue (on 2.3.1 and 2.3.4). Can you provide us with some extra debugging info?

The robots value should be resolved by Magento\Framework\View\Page\Config

/**
     * Retrieve URL to robots file
     *
     * @return string
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getRobots()
    {
        if ($this->getAreaResolver()->getAreaCode() !== Area::AREA_FRONTEND) {
            return 'NOINDEX,NOFOLLOW';
        }
        $this->build();
        if (empty($this->metadata[self::META_ROBOTS])) {
            $this->metadata[self::META_ROBOTS] = $this->scopeConfig->getValue(
                'design/search_engine_robots/default_robots',
                \Magento\Store\Model\ScopeInterface::SCOPE_STORE
            );
        }
        return $this->metadata[self::META_ROBOTS];
    }

And after that it will be processed by \Emico\Tweakwise\Model\Seo\Robots\Plugin

/**
     * @param PageConfig $config
     * @param $result
     * @return string
     */
    public function afterGetRobots(PageConfig $config, $result)
    {
        if (!$this->tweakwiseConfig->isSeoEnabled()) {
            return $result;
        }

        if ($this->isAlreadyNoIndex($result)) {
            return $result;
        }

        if (!$this->shouldApplyNoindex()) {
            return $result;
        }

        return $this->getNewRobots($result);
    }

Can you tell me what the initial outcome of getRobots is?