@param ProductInterface|string $code

@throws \RuntimeException

@return \Sonata\Component\Product\ProductProviderInterface
322680
public function getProvider($code)
    {
        if ($code instanceof ProductInterface) {
            $code = $this->getProductCode($code);

            if (!$code) {
                throw new \RuntimeException(sprintf('The class is not linked to a ProductProvider!'));
            }
        }

        return $this->getProduct($code)->getProvider();
    }
815380
public function getAdmin($code): Admin
    {
        if ($code instanceof Admin) {
            return $code;
        }

        return $this->adminRegistry->getAdmin($code);
    }
103434
private function provideProductAttribute($type, $name, $code = null)
    {
        $code = $code ?: StringInflector::nameToCode($name);

        /** @var ProductAttributeInterface $productAttribute */
        $productAttribute = $this->productAttributeRepository->findOneBy(['code' => $code]);
        if (null !== $productAttribute) {
            return $productAttribute;
        }

        $productAttribute = $this->createProductAttribute($type, $name, $code);
        $this->saveProductAttribute($productAttribute);

        return $productAttribute;
    }
515359
public function get( $code, $type = null )
	{
		if( isset( $this->prodmap[$code] ) ) {
			return $this->prodmap[$code];
		}

		$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );

		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'product.code', $code ) );

		$result = $manager->searchItems( $search );

		if( ( $item = reset( $result ) ) !== false )
		{
			$this->prodmap[$code] = $item->getId();
			return $this->prodmap[$code];
		}
	}
245238
private function removeProductCode($code)
    {
        $first3 = substr($code, 0, 3);

        // For ISBN-10, product code is always 978
        if (strlen($code) == 9) {
            $this->setProduct(978);
        }

        // ISBN-13: check that product code is 978 or 979
        elseif ($first3 == 978 || $first3 == 979) {
            $this->setProduct($first3);
            $code = substr($code, 3);
        }

        // Product code is Invalid
        else {
            $this->setValid(false);
            $this->addError(self::ERROR_INVALID_PRODUCT_CODE);
        }

        return $code;
    }
693151
public function getProductCode(ProductInterface $product)
    {
        foreach ($this->products as $code => $productDescription) {
            $className = $productDescription->getManager()->getClass();
            if ($product instanceof $className) {
                return $code;
            }
        }
    }
891022
public function getConfigurationEntityFromCode($code)
    {
        $dbConfiguration = IndexEngineIndexQuery::create()->findOneByCode($code);

        if (null === $dbConfiguration) {
            throw new InvalidArgumentException(sprintf("The index configuration code '%s' doesn't exist", $code));
        }

        return $this->getConfigurationEntityFromPropelEntity($dbConfiguration);
    }
434620
private function buildMenuFromRepository($menuCode)
    {
        $menu = $this
            ->menuRepository
            ->findOneBy([
                'code' => $menuCode,
                'enabled' => true,
            ]);

        if (!($menu instanceof MenuInterface)) {
            throw new Exception(sprintf(
                'Menu "%s" not found',
                $menuCode
            ));
        }

        $this
            ->menuObjectManager
            ->detach($menu);

        return $menu;
    }
1118424
private function createProductAttribute($type, $name, $code = null)
    {
        $productAttribute = $this->productAttributeFactory->createTyped($type);

        $code = $code ?: StringInflector::nameToCode($name);

        $productAttribute->setCode($code);
        $productAttribute->setName($name);

        return $productAttribute;
    }
63281
public function get($code) {
        $fields = Table::query()->setSelect(['*'])
            ->setFilter(['CODE' => trim($code)])
            ->exec()
            ->fetch();

        if (false === $fields) {
            $this->throwException(
                __METHOD__,
                'Delivery service [%s] not found.',
                $code
            );
        }

        return self::createObject($fields);
    }
1208815
protected function classForCode($code)
    {
        if (isset(self::$respClassMap[$code])) {
            return self::$respClassMap[$code];
        }

        return null;
    }
208814
protected function getQueryHandlerConfiguration(string $code): QueryHandlerConfigurationInterface
    {
        if (!array_key_exists($code, $this->queryHandlerConfigurations)) {
            return $this->buildQueryHandlerConfiguration($code);
        }

        return $this->queryHandlerConfigurations[$code];
    }
859780
public function onExecute($code)
    {
        foreach ($this->loopListeners as $listener) {
            if (($return = $listener->onExecute($this, $code)) !== null) {
                $code = $return;
            }
        }

        return $code;
    }
1111091
public function setCode($code){
        if(!$this->setModified('code', $code)->isModified()) {
            return $this;
        }
        $this->code = $code;

        return $this;
    }
513967
public function postFilter($code)
    {
        // run post filter if on code
        if (!empty($code) &&
            (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
        ) {
            return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
        } else {
            return $code;
        }
    }
1085083
public function setDefaultVersion(string $code)
    {
        if (! array_key_exists($code, $this->supportedVersions)) {
            throw new InvalidArgumentException("Unable to set [{$code}] as default version!");
        }

        $this->defaultVersion = $code;

        return $this;
    }
535897
public function code ( $code = NULL ) {
      if ( $code === NULL )
        return $this->code;
      if ( ResponseCode::find( $code ) === NULL )
        throw new \InvalidArgumentException( "Response: no code $code" );
      $this->code = intval( $code );
      return $this;
    }