protected function validateCategoryLinks(SimpleXMLElement $xml)
    {
        $categoryIdElements = $xml->xpath('/tweakwise/categories/category/categoryid');
        $categoryIds = array();
        foreach ($categoryIdElements as $id) {
            $categoryIds[] = (string) $id;
        }
        $categoryIds = array_flip($categoryIds);

        foreach ($xml->xpath('/tweakwise/categories/category/parents/categoryid') as $categoryIdElement) {
            $categoryId = (string) $categoryIdElement;
            if (!isset($categoryIds[$categoryId])) {
                throw new ValidationException(__(sprintf('Category parent reference %s not found', $categoryId)));
            }
        }

        foreach ($xml->xpath('/tweakwise/items/item/categories/categoryid') as $categoryIdElement) {
            $categoryId = (string) $categoryIdElement;
            if (!isset($categoryIds[$categoryId])) {
                throw new ValidationException(__(sprintf('Product category reference %s not found', $categoryId)));
            }
        }
    }
protected function validateCategoryLinks(SimpleXMLElement $xml)
    {
        $categoryIdElements = $xml->xpath('/tweakwise/categories/category/categoryid');
        $categoryIds = array();
        foreach ($categoryIdElements as $id) {
            $categoryIds[] = (string) $id;
        }
        $categoryIds = array_flip($categoryIds);

        foreach ($xml->xpath('/tweakwise/categories/category/parents/categoryid') as $categoryIdElement) {
            $categoryId = (string) $categoryIdElement;
            if (!isset($categoryIds[$categoryId])) {
                throw new ValidationException(__(sprintf('Category parent reference %s not found', $categoryId)));
            }
        }

        foreach ($xml->xpath('/tweakwise/items/item/categories/categoryid') as $categoryIdElement) {
            $categoryId = (string) $categoryIdElement;
            if (!isset($categoryIds[$categoryId])) {
                throw new ValidationException(__(sprintf('Product category reference %s not found', $categoryId)));
            }
        }
    }
protected function validateCategoryLinks ( SimpleXMLElement $ xml ) { $ categoryIdElements = $ xml -> xpath ( '/tweakwise/categories/category/categoryid' ) ; $ categoryIds = array ( ) ; foreach ( $ categoryIdElements as $ id ) { $ categoryIds [ ] = ( string ) $ id ; } $ categoryIds = array_flip ( $ categoryIds ) ; foreach ( $ xml -> xpath ( '/tweakwise/categories/category/parents/categoryid' ) as $ categoryIdElement ) { $ categoryId = ( string ) $ categoryIdElement ; if ( ! isset ( $ categoryIds [ $ categoryId ] ) ) { throw new ValidationException ( __ ( sprintf ( 'Category parent reference %s not found' , $ categoryId ) ) ) ; } } foreach ( $ xml -> xpath ( '/tweakwise/items/item/categories/categoryid' ) as $ categoryIdElement ) { $ categoryId = ( string ) $ categoryIdElement ; if ( ! isset ( $ categoryIds [ $ categoryId ] ) ) { throw new ValidationException ( __ ( sprintf ( 'Product category reference %s not found' , $ categoryId ) ) ) ; } } }
Validate category parent en product category references.

@param SimpleXMLElement $xml
@throws ValidationException
Validate category parent en product category references .