Return's TRUE, if the passed URL key varchar value IS related with the actual PK.

@param array $productVarcharAttribute The varchar value to check

@return boolean TRUE if the URL key is related, else FALSE
349070
public function isUrlKeyOf(array $productVarcharAttribute)
    {
        return ((integer) $productVarcharAttribute[MemberNames::ROW_ID] === (integer) $this->getLastRowId()) &&
               ((integer) $productVarcharAttribute[MemberNames::STORE_ID] === (integer) $this->getRowStoreId(StoreViewCodes::ADMIN));
    }
604226
private function assertProductIsInAssociation($productName, $productAssociationName)
    {
        Assert::true(
            $this->showPage->hasProductInAssociation($productName, $productAssociationName),
            sprintf(
                'There should be an associated product "%s" under association "%s" but it does not.',
                $productName,
                $productAssociationName
            )
        );
    }
679888
protected function match(RecordInterface $record, $query): bool
    {
        if ($record === $query) {
            //Strict search
            return true;
        }

        //Primary key comparision
        if (is_scalar($query) && $record->primaryKey() == $query) {
            return true;
        }

        //Record based comparision
        if ($query instanceof RecordInterface) {
            //Matched by PK (assuming both same class)
            if (!empty($query->primaryKey()) && $query->primaryKey() == $record->primaryKey()) {
                return true;
            }

            //Matched by content (this is a bit tricky!)
            if ($record->packValue() == $query->packValue()) {
                return true;
            }

            return false;
        }

        //Field intersection
        if (is_array($query) && array_intersect_assoc($record->packValue(), $query) == $query) {
            return true;
        }

        return false;
    }
101321
protected function validateRelatedProduct()
    {
        $field = 'related';

        if ($this->isExcluded($field) || $this->isError('store_id')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (empty($value)) {
            $this->setSubmitted($field, array());
            return null;
        }

        $store_id = $this->getSubmitted('store_id');

        $product_ids = array();

        foreach (array_unique($value) as $product_id) {

            $product = $this->product->get($product_id);

            if (empty($product['store_id'])) {
                $this->setError($field, $this->translation->text('Some of related products are invalid'));
                return false;
            }

            if ($product['store_id'] != $store_id) {
                $this->setError($field, $this->translation->text('All related product must belong to the same store'));
                return false;
            }

            $product_ids[$product['product_id']] = $product['product_id'];
        }

        $updating = $this->getUpdating();

        if (isset($updating['product_id'])) {
            // Exclude the current product from the related products
            unset($product_ids[$updating['product_id']]);
        }

        $this->setSubmitted('related', $product_ids);
        return true;
    }
550107
public function hit($pk = null)
	{
		// If there is no hits field, just return true.
		if (!property_exists($this, 'hits'))
		{
			return true;
		}

		// Initialise variables.
		$k = $this->_tbl_key;
		$pk = (is_null($pk)) ? $this->$k : $pk;

		// If no primary key is given, return false.
		if ($pk === null)
		{
			return false;
		}

		// Check the row in by primary key.
		$query = $this->_db->getQuery();
		$query->update($this->_tbl);
		$query->set(array(
			'hits' => new \Hubzero\Database\Value\Raw('(hits + 1)')
		));
		$query->whereEquals($this->_tbl_key, $pk);
		$this->_db->setQuery($query->toString());

		// Check for a database error.
		if (!$this->_db->execute())
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_HIT_FAILED', get_class($this), $this->_db->getErrorMsg()));
			$this->setError($e);
			return false;
		}

		// Set table values in the object.
		$this->hits++;

		return true;
	}
117069
public function update($product_id, array $data)
    {
        $result = null;
        $this->hook->attach('product.update.before', $product_id, $data, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        $data['modified'] = GC_TIME;
        $data['product_id'] = $product_id;

        $this->setPrice($data);

        $updated = $this->db->update('product', $data, array('product_id' => $product_id));

        $updated += (int) $this->setSku($data);
        $updated += (int) $this->setTranslations($data, $this->translation_entity, 'product');
        $updated += (int) $this->setImages($data, $this->file, 'product');
        $updated += (int) $this->setAlias($data, $this->alias, 'product');
        $updated += (int) $this->setSkuCombinations($data);
        $updated += (int) $this->setOptions($data);
        $updated += (int) $this->setAttributes($data);
        $updated += (int) $this->setRelated($data);

        $result = $updated > 0;

        if ($result) {
            $this->search->index('product', $product_id);
        }

        $this->hook->attach('product.update.after', $product_id, $data, $result, $this);
        return (bool) $result;
    }
909687
public function getCreateVariant($product_id)
    {
        $product = Product::find($product_id);
        // No such id
        if ($product == null) {
            $errors = new MessageBag;
            $errors->add('errorNoSuchProduct', Lang::get('redminportal::messages.error_no_such_product'));
            return redirect($this->pageRoute)->withErrors($errors);
        }
        
        $data = array(
            'product' => $product,
            'product_id' => $product_id,
            'weight_units' => $this->weight_units,
            'volume_units' => $this->volume_units
        );

        return view('redminportal::products/create-variant', $data);
    }
824248
public function is_related($query) {
        if (parent::is_related($query)) {
            return true;
        }

        $antivirusesavailable = \core\antivirus\manager::get_available();
        foreach ($antivirusesavailable as $antivirus => $antivirusstr) {
            if (strpos($antivirus, $query) !== false) {
                return true;
            }
            if (strpos(core_text::strtolower($antivirusstr), $query) !== false) {
                return true;
            }
        }
        return false;
    }
970582
protected function realPkSelection(&$pk)
  {
    if ( null === $pk ){
      $pk = $this->row->get($this->tbl_key);
    }
    
    if ( null === $pk ){
      $this->setError( DatabaseHelper::getTranslation('NO_ITEM_SELECTED') );
      return false;
    }
    
    return true;
  }
776481
def is_related_to(item, app_id, app_ver=None):
    """"""
    versionRange = item.get('versionRange')
    if not versionRange:
        return True

    for vR in versionRange:
        if not vR.get('targetApplication'):
            return True
        if get_related_targetApplication(vR, app_id, app_ver) is not None:
            return True
    return False
260117
private function _getRelatedFks($data, $relation, $modelClass)
    {
        $fks = [];
        if (is_array($data)) {
            // Get the right link definition
            if ($relation->via instanceof BaseActiveRecord) {
                $link = $relation->via->link;
            } elseif (is_array($relation->via)) {
                list($viaName, $viaQuery) = $relation->via;
                $link = $viaQuery->link;
            } else {
                $link = $relation->link;
            }
            // search PK
            foreach ($modelClass::primaryKey() as $modelAttribute) {
                if (isset($data[$modelAttribute])) {
                    $fks[$modelAttribute] = $data[$modelAttribute];
                } elseif ($relation->multiple && !$relation->via) {
                    foreach ($link as $relatedAttribute => $relatedModelAttribute) {
                        if (!isset($data[$relatedAttribute]) && in_array($relatedAttribute, $modelClass::primaryKey())) {
                            $fks[$relatedAttribute] = $this->owner->{$relatedModelAttribute};
                        }
                    }
                } else {
                    $fks = [];
                    break;
                }
            }
            if (empty($fks)) {
                foreach ($link as $relatedAttribute => $modelAttribute) {
                    if (isset($data[$modelAttribute])) {
                        $fks[$modelAttribute] = $data[$modelAttribute];
                    }
                }
            }
        } else {
            $fks = $data;
        }
        return $fks;
    }
1198222
protected function isPk($key)
    {
        $pk = $this->getPk();
        if (is_string($pk) && $pk == $key) {
            return true;
        } elseif (is_array($pk) && in_array($key, $pk)) {
            return true;
        }

        return false;
    }
689427
protected function relate($remote, $intermediates, $remoteColumn, $localColumn, $localValue)
    {
        $intermediates = $this->intermediates($intermediates, $localColumn, $localValue);
        //
        if (!is_null($intermediates)) {
            return $this->all($intermediates, $remote, $remoteColumn);
        }
        //
    }
1194129
public function keyedArray($subject) : bool
    {
        if (!is_array($subject)) {
            return false;
        }
        if (!$subject) {
            return true;
        }
        return !ctype_digit(join('', array_keys($subject)));
    }
228104
protected function isRelationTable($table)
	{
		$pk=$table->primaryKey;
        $count=is_array($pk) ? count($pk) : 1;
        return ($count === 2 // we want 2 columns
			&& isset($table->foreignKeys[$pk[0]]) // pk column 1 is also a foreign key
			&& isset($table->foreignKeys[$pk[1]]) // pk column 2 is also a foriegn key
			&& $table->foreignKeys[$pk[0]][0] !== $table->foreignKeys[$pk[1]][0]); // and the foreign keys point different tables
	}
1158126
public function hasRelatedKey($key, $model = false)
    {
        if (!$model) {
            $model = $this->model;
        }

        if (($methodBreaker = strpos($key, '.')) !== false) {
            $method = substr($key, 0, $methodBreaker);
            if (method_exists($model, $method)) {
                return true;
            }
        }

        return false;
    }
211077
private function getMatchQueryParams(ProductCondition $productCondition)
    {
        $fieldName          = $this->getSearchFieldName($productCondition);
        $queryText          = $productCondition->getValue();
        $minimumShouldMatch = "100%";

        return ['field' => $fieldName, 'queryText' => $queryText, 'minimumShouldMatch' => $minimumShouldMatch];
    }