src/Observers/UrlRewriteUpdateObserver.php
protected function initializeUrlRewrite(array $attr)
    {

        // load store ID and request path
        $categoryId = $attr[MemberNames::ENTITY_ID];
        $requestPath = $attr[MemberNames::REQUEST_PATH];

        // iterate over the available URL rewrites to find the one that matches the category ID
        foreach ($this->existingUrlRewrites as $urlRewrite) {
            // compare the category IDs AND the request path
            if ($categoryId === $urlRewrite[MemberNames::ENTITY_ID] &&
                $requestPath === $urlRewrite[MemberNames::REQUEST_PATH]
            ) {
                // if a URL rewrite has been found, do NOT create a redirect
                $this->removeExistingUrlRewrite($urlRewrite);

                // if the found URL rewrite has been created manually
                if ((integer) $urlRewrite[MemberNames::IS_AUTOGENERATED] === 0 && (integer) $urlRewrite[MemberNames::REDIRECT_TYPE] === 0) {
                    // do NOT update it nor create a another redirect
                    return false;
                }

                // if the found URL rewrite has been autogenerated, then update it
                return $this->mergeEntity($urlRewrite, $attr);
            }
        }

        // simple return the attributes
        return $attr;
    }
protected function initializeUrlRewrite(array $attr)
    {

        // load store ID and request path
        $categoryId = $attr[MemberNames::ENTITY_ID];
        $requestPath = $attr[MemberNames::REQUEST_PATH];

        // iterate over the available URL rewrites to find the one that matches the category ID
        foreach ($this->existingUrlRewrites as $urlRewrite) {
            // compare the category IDs AND the request path
            if ($categoryId === $urlRewrite[MemberNames::ENTITY_ID] &&
                $requestPath === $urlRewrite[MemberNames::REQUEST_PATH]
            ) {
                // if a URL rewrite has been found, do NOT create a redirect
                $this->removeExistingUrlRewrite($urlRewrite);

                // if the found URL rewrite has been created manually
                if ((integer) $urlRewrite[MemberNames::IS_AUTOGENERATED] === 0 && (integer) $urlRewrite[MemberNames::REDIRECT_TYPE] === 0) {
                    // do NOT update it nor create a another redirect
                    return false;
                }

                // if the found URL rewrite has been autogenerated, then update it
                return $this->mergeEntity($urlRewrite, $attr);
            }
        }

        // simple return the attributes
        return $attr;
    }
protected function initializeUrlRewrite ( array $ attr ) { // load store ID and request path $ categoryId = $ attr [ MemberNames :: ENTITY_ID ] ; $ requestPath = $ attr [ MemberNames :: REQUEST_PATH ] ; // iterate over the available URL rewrites to find the one that matches the category ID foreach ( $ this -> existingUrlRewrites as $ urlRewrite ) { // compare the category IDs AND the request path if ( $ categoryId === $ urlRewrite [ MemberNames :: ENTITY_ID ] && $ requestPath === $ urlRewrite [ MemberNames :: REQUEST_PATH ] ) { // if a URL rewrite has been found, do NOT create a redirect $ this -> removeExistingUrlRewrite ( $ urlRewrite ) ; // if the found URL rewrite has been created manually if ( ( integer ) $ urlRewrite [ MemberNames :: IS_AUTOGENERATED ] === 0 && ( integer ) $ urlRewrite [ MemberNames :: REDIRECT_TYPE ] === 0 ) { // do NOT update it nor create a another redirect return false ; } // if the found URL rewrite has been autogenerated, then update it return $ this -> mergeEntity ( $ urlRewrite , $ attr ) ; } } // simple return the attributes return $ attr ; }
Initialize the URL rewrite with the passed attributes and returns an instance.

@param array $attr The URL rewrite attributes

@return array The initialized URL rewrite
Initialize the URL rewrite with the passed attributes and returns an instance .