Skip to content

Commit

Permalink
Merge pull request #43 from Datatrics/release/1.7.0
Browse files Browse the repository at this point in the history
Release/1.7.0
  • Loading branch information
Marvin-Magmodules authored Aug 31, 2023
2 parents 28380bf + 3e3745d commit 9344c73
Show file tree
Hide file tree
Showing 86 changed files with 2,139 additions and 2,822 deletions.
7 changes: 7 additions & 0 deletions Api/Config/System/ContentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ interface ContentInterface extends RepositoryInterface
*/
public function isEnabled(int $storeId = null): bool;

/**
* Get all enabled store Ids for content update
**
* @return array
*/
public function getContentEnabledStoreIds(): array;

/**
* Returns array of attributes
*
Expand Down
53 changes: 20 additions & 33 deletions Api/Content/DataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,50 @@
interface DataInterface extends ExtensibleDataInterface
{

/**#@+
/**
* Constants for keys of data array. Identical to the name of the getter in snake case
*/
public const ENTITY_ID = 'entity_id';
public const STORE_ID = 'store_id';
public const CONTENT_ID = 'content_id';
public const PRODUCT_ID = 'product_id';
public const PARENT_ID = 'parent_id';
public const CREATED_AT = 'created_at';
public const UPDATED_AT = 'updated_at';
public const UPDATE_MSG = 'update_msg';
public const UPDATE_ATTEMPTS = 'update_attempts';
public const STATUS = 'status';
/**#@-*/

/**
* @return string
* @return int
*/
public function getContentId() : string;
public function getProductId(): int;

/**
* @param string $contentId
* @param int $productId
* @return $this
*/
public function setContentId(string $contentId) : self;
public function setProductId(int $productId): self;

/**
* @return string
* @return ?int
*/
public function getParentId() : string;
public function getParentId(): ?int;

/**
* @param string $parentId
* @param ?int $parentId
* @return $this
*/
public function setParentId(string $parentId) : self;
public function setParentId(?int $parentId): self;

/**
* @return int
*/
public function getStoreId() : int;
public function getStoreId(): int;

/**
* @param int $storeId
* @return $this
*/
public function setStoreId(int $storeId) : self;

/**
* @return string
*/
public function getCreatedAt() : string;

/**
* @param string $createdAt
* @return $this
*/
public function setCreatedAt(string $createdAt) : self;
public function setStoreId(int $storeId): self;

/**
* @return string
Expand All @@ -83,38 +70,38 @@ public function getUpdatedAt(): string;
* @param string $updatedAt
* @return $this
*/
public function setUpdatedAt(string $updatedAt) : self;
public function setUpdatedAt(string $updatedAt): self;

/**
* @return string
*/
public function getUpdateMsg() : string;
public function getUpdateMsg(): string;

/**
* @param string $updateMsg
* @return $this
*/
public function setUpdateMsg(string $updateMsg) : self;
public function setUpdateMsg(string $updateMsg): self;

/**
* @return string
* @return int
*/
public function getUpdateAttempts() : string;
public function getUpdateAttempts(): int;

/**
* @param int $updateAttempts
* @return $this
*/
public function setUpdateAttempts(int $updateAttempts) : self;
public function setUpdateAttempts(int $updateAttempts): self;

/**
* @return string
*/
public function getStatus() : string;
public function getStatus(): string;

/**
* @param string $status
* @return $this
*/
public function setStatus(string $status) : self;
public function setStatus(string $status): self;
}
30 changes: 11 additions & 19 deletions Api/Content/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@

namespace Datatrics\Connect\Api\Content;

use Datatrics\Connect\Api\Content\DataInterface as ContentData;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Datatrics\Connect\Api\Content\DataInterface
as ContentData;
use Datatrics\Connect\Api\Content\SearchResultsInterface;
use Magento\Customer\Model\Customer;

/**
* Interface Repository
Expand Down Expand Up @@ -43,12 +40,13 @@ interface RepositoryInterface
public const COULD_NOT_SAVE_EXCEPTION = 'Could not save the entity: %1';

/**
*
* Content status key-pair
*/
public const STATUS = [
'queued' => 'Queued for Update',
'synced' => 'Synced',
'error' => 'Error',
'skipped' => 'Skipped',
'failed' => 'Failed'
];

Expand All @@ -60,24 +58,24 @@ interface RepositoryInterface
* @return ContentData
* @throws LocalizedException
*/
public function get(int $entityId) : ContentData;
public function get(int $entityId): ContentData;

/**
* Return Content object
*
* @return ContentData
*/
public function create();
public function create(): DataInterface;

/**
* Retrieves an Content matching the specified criteria.
* Retrieves a Content matching the specified criteria.
*
* @param SearchCriteriaInterface $searchCriteria
*
* @return SearchResultsInterface
* @throws LocalizedException
*/
public function getList(SearchCriteriaInterface $searchCriteria) : SearchResultsInterface;
public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface;

/**
* Register entity to delete
Expand All @@ -87,18 +85,18 @@ public function getList(SearchCriteriaInterface $searchCriteria) : SearchResults
* @return bool true on success
* @throws LocalizedException
*/
public function delete(ContentData $entity) : bool;
public function delete(ContentData $entity): bool;

/**
* Deletes a Content entity by ID
*
* @param int $entity
* @param int $entityId
*
* @return bool true on success
* @throws NoSuchEntityException
* @throws LocalizedException
*/
public function deleteById(int $entity) : bool;
public function deleteById(int $entityId): bool;

/**
* Perform persist operations for one entity
Expand All @@ -108,11 +106,5 @@ public function deleteById(int $entity) : bool;
* @return ContentData
* @throws LocalizedException
*/
public function save(ContentData $entity) : ContentData;

/**
* @param array $productIds
* @return mixed
*/
public function prepareContentData(array $productIds);
public function save(ContentData $entity): ContentData;
}
4 changes: 2 additions & 2 deletions Block/Adminhtml/Datatrics/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function render(AbstractElement $element): string
$html = '<tr id="row_' . $element->getHtmlId() . '">';
$html .= ' <td class="label"></td>';
$html .= ' <td class="value">';
$html .= ' <div class="mm-heading-block">' . $element->getData('label') . '</div>';
$html .= ' <div class="mm-heading-comment">' . $element->getData('comment') . '</div>';
$html .= ' <div class="mm-datatrics-heading-block">' . $element->getData('label') . '</div>';
$html .= ' <div class="mm-datatrics-heading-comment">' . $element->getData('comment') . '</div>';
$html .= ' </td>';
$html .= ' <td></td>';
$html .= '</tr>';
Expand Down
54 changes: 16 additions & 38 deletions Block/Adminhtml/System/Config/Button/DebugCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Datatrics\Connect\Block\Adminhtml\System\Config\Button;

use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

Expand All @@ -23,66 +23,44 @@ class DebugCheck extends Field
protected $_template = 'Datatrics_Connect::system/config/button/debug.phtml';

/**
* @var \Magento\Framework\App\RequestInterface
* @inheritDoc
*/
private $request;

/**
* Credentials constructor.
*
* @param Context $context
* @param array $data
*/
public function __construct(
Context $context,
array $data = []
) {
$this->request = $context->getRequest();
parent::__construct($context, $data);
}

/**
* @param AbstractElement $element
*
* @return string
*/
public function render(AbstractElement $element)
public function render(AbstractElement $element): string
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}

/**
* @param AbstractElement $element
*
* @return string
* @inheritDoc
*/
public function _getElementHtml(AbstractElement $element)
public function _getElementHtml(AbstractElement $element): string
{
return $this->_toHtml();
}

/**
* @return string
*/
public function getDebugCheckUrl()
public function getDebugCheckUrl(): string
{
return $this->getUrl('datatrics/log/debug');
return $this->getUrl('datatrics/log/stream', ['type' => 'debug']);
}

/**
* @return mixed
* @return string
*/
public function getButtonHtml()
public function getButtonHtml(): string
{
$buttonData = ['id' => 'mm-button_debug', 'label' => __('Check last 100 debug log records')];
try {
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
)->setData($buttonData);
return $button->toHtml();
return $this->getLayout()
->createBlock(Button::class)
->setData([
'id' => 'mm-datatrics-button_debug',
'label' => __('Check last 50 debug log records')
])->toHtml();
} catch (\Exception $e) {
return false;
return '';
}
}
}
Loading

0 comments on commit 9344c73

Please sign in to comment.